Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 03:16 24 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Really strange graphics bug - what am I doing wrong?

Author Message
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 05:16pm 02 Aug 2020
Copy link to clipboard 
Print this post

I'm testing out some code and trying to learn how the system works, so I'm writing a "Depthcharge" game as my coding exercise. I have the ship animated when I use the arrow keys to move it left and right, and I have up to 6 depth charges falling through the water. No submarines yet, and the depth charges are all dropped at once just to test the animation. Problem is, half the time when I run the game it fills the screen with a goofy colors instead of what it's supposed to look like. It seems to happen most often when I go directly from editing to running with F1 and then F2.

I figure I must be setting something up wrong to cause this, but I'm at a loss to figure it out.

Code and images attached if anyone feels like taking a look and getting me straightened out. Any help would be greatly appreciated.


test.zip
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 06:03pm 02 Aug 2020
Copy link to clipboard 
Print this post

I see strange colours too when I test your program. As you say, often if you run (F2) from the editor, the colour mapping is all messed up. If you stop the program with CTL-C and type RUN, it works fine again. Also, if you use mode 1,8 (instead of mode 1,16) the colours seem to stay correct.

But there is something else weird. If you sail your battleship completely off the left or right side of the screen, the saved background image for the sprites is taken from page 1 instead of page 0. In this case, the destination for the blit command is so far off screen that no pixels are copied. Somehow this appears to disturb which page a sprite's background image is take from.

Both of these might be bugs that matherp should comment on.
Visit Vegipete's *Mite Library for cool programs.
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 07:13pm 02 Aug 2020
Copy link to clipboard 
Print this post

I hadn't noticed that running the ship off the screen caused problems. This is just a mock-up for testing, so I hadn't put limits on the battleship movement.

I should mention also that the battleship itself is not a sprite, but a blit'd bitmap. I wasn't sure what the size limit was on a sprite. One place manual says one thing, and a different place it says something different (16x16 vs MM.HRES-1,MM.VRES-1) I didn't really see the necessity for using a sprite for the ship anyway.
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 08:13pm 02 Aug 2020
Copy link to clipboard 
Print this post

Another odd occurrence I just noticed: I had a comment that included a double quote. Specifically:

if ldb = -1 then ldb = 0 ' launch key "debounce"

I got the error message "Unexpected text" so I deleted the comment. Now there is no double quote anywhere on the line yet it still gives me the "Unexpected text" error message.

Powering down and rebooting still gives me the "unexpected text" message.
Removing the line and retyping it still gives me the same error message.
That line is poison now. I can't get past it.

I finally deleted the whole section and rewrote it a different way to get the error message to go away.
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 08:43pm 02 Aug 2020
Copy link to clipboard 
Print this post

Also, I'm not finding the command to position the text cursor to a particular x,y location. In otherwords, the way to set MM.INFO(HPOS) and MM.INFO(VPOS)

On edit: Never mind: I'm using text x,y,"" with dummy text to relooate the cursor. That works.
Edited 2020-08-03 07:01 by fiziwig
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 08:58pm 02 Aug 2020
Copy link to clipboard 
Print this post

  fiziwig said  Also, I'm not finding the command to position the text cursor to a particular x,y location. In otherwords, the way to set MM.INFO(HPOS) and MM.INFO(VPOS)


I think you can just do ?@(x,y)
That will move the cursor to that location, then you can do whatever after that.
I'm not sure if it stays there though.
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 09:08pm 02 Aug 2020
Copy link to clipboard 
Print this post

  Atomizer_Zero said  
  fiziwig said  Also, I'm not finding the command to position the text cursor to a particular x,y location. In otherwords, the way to set MM.INFO(HPOS) and MM.INFO(VPOS)


I think you can just do ?@(x,y)
That will move the cursor to that location, then you can do whatever after that.
I'm not sure if it stays there though.


Thanks! I didn't see that in the manual. Like whenever I'm dealing with a new system I don't know where to find things in the manual until AFTER I've found them in the manual, but then it's too late to learn the answer because by then I already know the answer.

Catch22 (hehe) you can only learn what you already know, so if you don't already know it, you can't learn it. Or so it seems at times.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8573
Posted: 09:24pm 02 Aug 2020
Copy link to clipboard 
Print this post

  Quote   Problem is, half the time when I run the game it fills the screen with a goofy colors instead of what it's supposed to look like. It seems to happen most often when I go directly from editing to running with F1 and then F2.


How come you just start using the system and find a bug no-one else has found in weeks of use by dozens of people

Thanks for the report - I'll try and fix it
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 10:09pm 02 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote   Problem is, half the time when I run the game it fills the screen with a goofy colors instead of what it's supposed to look like. It seems to happen most often when I go directly from editing to running with F1 and then F2.


How come you just start using the system and find a bug no-one else has found in weeks of use by dozens of people

Thanks for the report - I'll try and fix it


Sorry about that     BTW: I'm using version 5.0504 According to MM.INFO(VERSION)
Edited 2020-08-03 08:11 by fiziwig
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8573
Posted: 10:19am 03 Aug 2020
Copy link to clipboard 
Print this post

Found the bug and will fix in the next beta

The workround for 5.05.04 is to set the mode to 1,8 and then 1,16

Option Default Integer
Option Base 1
 Mode 1,8
 Mode 1,16

Edited 2020-08-03 21:16 by matherp
 
fiziwig
Newbie

Joined: 09/07/2020
Location: United States
Posts: 22
Posted: 05:11pm 04 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  Found the bug and will fix in the next beta

The workround for 5.05.04 is to set the mode to 1,8 and then 1,16

Option Default Integer
Option Base 1
 Mode 1,8
 Mode 1,16


I found that the program works fine and displays correctly in mode 1,8 so I'm just going to leave it that way. Thanks.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024