Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:03 14 Nov 2025 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 : Couple things I'm struggling with

Author Message
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 02:13pm 30 Jul 2020
Copy link to clipboard 
Print this post

Ok, I'm hoping somebody can explain this in a way that will finally sink into my thick head because I'm struggling with it...

First off, I get the concept of screen pages - page write n  to set which page you're going to write onto, etc. page copy n to m to copy it over...

I get sprites being things that can be set into different layers such that they only report collisions with other sprites in the same layer.

What I don't get is the following:

Using mode 1,8

I load in a BMP for my background into layer 1
I load my sprite in on layer 1
I copy layer 1 to 0 (display)
I try to use page scroll (or sprite scroll seems to be similar effect) then on page 1, and the sprite ends up getting smeared along the way. I thought sprites sat separately from the actual layer data and were overlaid on top?

Seems like the only way I could fix this was on each cycle to hide all sprites, do the scroll on page 1, then reshow all sprites....


I'm also really not getting how to use the transparency layers... and page copying to reduce flickering at the same time... When I tried I ended up with a horrible flickering mess of a screen.

What I'd like to do is have 1 background layer which is the "ground", another layer which is just the road surface, and finally the sprites. I'd like the ground and the road surface scroll at slightly different rates, but neither should interact with the cars at all (I'm only concerned with car-car collisions at this point), and do this with buffering so there's no flickering...


Also, (and maybe this is obvious because it's so many less pixels to move around), I've found that it's a little bit faster to use SCROLLR to move just the dashed lane lines vs. SCROLL of the whole road surface.




Next up - Music playback w/sound effects.

When I try to say Play an MP3 as background music in my game, and then play a tone (for like a car engine sound) it complains that it can't because channel is in use (or something to that effect, it's been a few days since I've tried.) I see in the manual that it says you can play MOD files and .wav sound effects at the same time. Is that the only way?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 02:30pm 30 Jul 2020
Copy link to clipboard 
Print this post

  Quote  I try to use page scroll (or sprite scroll seems to be similar effect) then on page 1, and the sprite ends up getting smeared along the way. I thought sprites sat separately from the actual layer data and were overlaid on top?


First point - it is not impossible there are bugs as this functionality is both complex and difficult to test thoroughly.
Second point  - layers and pages are unrelated. Layers are just a mechanism for controlling collisions and in the specific case of layer 0 whether sprites scroll with the background. Pages are the physical video framebuffers in memory.

However, in your case:
Only SPRITE SCROLL will leave sprites on layers other than 0 unmoved
SPRITE SCROLL will only work when PAGE WRITE is set to the page on which the sprites are written. As soon as you page copy you flatten the image

so the following should work:

]
page write 1
sprite show 1,100,100,2
do
 sprite scroll 5,5
 pause 500
loop
page copy 1 to 0


  Quote   I see in the manual that it says you can play MOD files and .wav sound effects at the same time. Is that the only way?

Yes: mod files are loaded into memory so don't need any disk access after the first load. Trying to play mp3 and Wav at the same time would kill any other processing
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 342
Posted: 03:09pm 30 Jul 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Ok, I'm hoping somebody can explain this in a way that will finally sink into my thick head because I'm struggling with it...

First off, I get the concept of screen pages - page write n  to set which page you're going to write onto, etc. page copy n to m to copy it over...

I get sprites being things that can be set into different layers such that they only report collisions with other sprites in the same layer.

What I don't get is the following:

Using mode 1,8

I load in a BMP for my background into layer 1
I load my sprite in on layer 1
I copy layer 1 to 0 (display)
I try to use page scroll (or sprite scroll seems to be similar effect) then on page 1, and the sprite ends up getting smeared along the way. I thought sprites sat separately from the actual layer data and were overlaid on top?

Most of these use pages, not layers. As Peter said they are unrelated.
  Quote  

Seems like the only way I could fix this was on each cycle to hide all sprites, do the scroll on page 1, then reshow all sprites....


I haven't used sprite layers yet, but I have used pages.

If you can't get sprite layers scrolling working, you could have the sprites all on page 2, do the scroll on page 1,  combine page 1 and 2 into page 3 using BLIT (with "don't copy transparent pixels" when you copy the sprites page, so the background shows through behind them). Then copy page 3 to page 0.

But it would also be good to make sure sprite layers are working properly and usable.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 06:13pm 30 Jul 2020
Copy link to clipboard 
Print this post

I guess it's just the overall philosophy of operation I'm confused on...

I come from the C64 world where the sprites live over the top of the graphics display, you can change the graphics screen all you want and the sprites will be on top.  (as though they were on another layer over the top).


I know Screen 0 is the foreground. I've used 1 as  sort of the back buffer so I do everything into that to compose the new frame and then copy over to 0 to display while I go work on building the next frame in screen 1, and so on.

I'm not getting how that works when using the 12 bit mode with transparency.

Guess I just need to play around with it more. Just doesn't seem to work the way I thought it did.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 342
Posted: 12:46am 31 Jul 2020
Copy link to clipboard 
Print this post

  mkopack73 said  I guess it's just the overall philosophy of operation I'm confused on...


Me too (specifically with sprites and sprite layers), but it may be that the system supports a couple of different styles of operation. There are a few I've been thinking of trying out:

Non-overlapping sprites, so I don't have to worry about which is drawn in front of the other. This might mean I can't use the built in collision detection to enforce the non-overlapping part, as I think it only detects them after they overlap.

Getting the system to automatically hide/redraw the sprites as needed. I may be able to do this with SPRITE MOVE/SCROLL/SCROLLR/NEXT. This is my favourite idea, but I haven't tried or or worked out how to do a few things without corrupting the display:
Drawing the background behind the sprites, when it scrolls in from the edge.
Changing the background behind the sprites in general.
Using SPRITE SWAP on a sprite behind another sprite (it may just work, I don't know)
Removing a sprite behind another sprite. Could use SPRITE SWAP once that's tested as working but it's probably not the simplest way.

Having the background and sprites on separate pages, though that means SPRITE SCROLL/SCROLLR isn't so much use (it could still scroll the sprites on layer 0 though).

Manually hiding and redrawing the sprites when making changes - this doesn't appeal so much, but I think it would be possible.

  Quote  
I come from the C64 world where the sprites live over the top of the graphics display, you can change the graphics screen all you want and the sprites will be on top.  (as though they were on another layer over the top).


I know Screen 0 is the foreground. I've used 1 as  sort of the back buffer so I do everything into that to compose the new frame and then copy over to 0 to display while I go work on building the next frame in screen 1, and so on.

I'm not getting how that works when using the 12 bit mode with transparency.

Guess I just need to play around with it more. Just doesn't seem to work the way I thought it did.
 
Atomizer_Zero
Senior Member

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

I didn't want to start a new thread regarding page scrolling, sprite routines and such, considering this thread has had much the same discussion that i've gone through in my head while coding lol

So, i'll continue it on from here.

Using 12 bit mode. Essentially, I have the level on background page 0. I have sprites on page 1. I use page scroll to scroll in the direction I want, and do level loading stuff at the same time. Seems to work fine.

So, I use "Sprite SHOW" to draw the sprites, and have to use "sprite HIDE" when I scroll background page 0, because if I don't, then the tile the sprite is on will get replaced with whatever the tile was when I started the scroll. This is working well enough for my game right now.

The issue i'm having is that my sprites are flickering all the time. I'm not sure why though. If I use "Sprite WRITE" instead, the flickering stops (as far as I can see), but of course, the sprite just smears when you move it. I'm "OK" with it flickering for now, and will continue developing my game, but if anyone has any suggestions regarding this issue, I'd love to hear it.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 08:12am 09 Aug 2020
Copy link to clipboard 
Print this post

  Quote  The issue i'm having is that my sprites are flickering all the time.


Move all the sprites to page 2. Then at each relevant point page copy page 2 to page 1
Edited 2020-08-09 18:13 by matherp
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 09:40am 09 Aug 2020
Copy link to clipboard 
Print this post

@mkopack73

One of the things that is important to grasp (as Peter indicated), layers and pages are different.

In 12 bit mode where there are 3 layers and their relationship to pages is:-

Layer 1 is Page 2 and is the rear 'layer',
Layer 2 is Page 0 and is the ONLY page that is displayed (subject to transparency of itself and the 'front' layer)
Layer 3 is Page 1 and is the 'front' layer.

Transparency in Page 0 and Page 1 can determine what part of the image that is displayed by Page 0.  The detailed description in  
Graphics Programming on the CMM2-v1.0E.pdf that Peter wrote details this relationship in the section on 12 bit graphics modes.

panky.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 10:12am 09 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  The issue i'm having is that my sprites are flickering all the time.


Move all the sprites to page 2. Then at each relevant point page copy page 2 to page 1


I seeee...

So i've just tried that out, but I appear to be getting a horizontal line across a portion of the screen thats completely blanked out on page 1.



This line looks like a horizontal blanking line to me, as it flickers somewhat. It doesn't appear to be happening anywhere else on the screen. Just across this one horizontal stretch.

here's my loop currently
DO
SPRITE SHOW 1, X, Y, 2
PAGE COPY 2, 1, B
KEYS() ' CHECK FOR KEY INPUT
PLAYERUPDATE() 'MOVES X AND Y BASED ON INPUT
LOOP

Edited 2020-08-09 20:13 by Atomizer_Zero
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 10:43am 09 Aug 2020
Copy link to clipboard 
Print this post

So, further to this, if I put PAGE COPY 2,1,B at the end of my loop, then one quarter  horizontally at the bottom of the screen is blank.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 11:37am 09 Aug 2020
Copy link to clipboard 
Print this post

Neither of those symptoms sound correct. If you post the code I can run it and see if I can replicate
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 12:06pm 09 Aug 2020
Copy link to clipboard 
Print this post

https://www.dropbox.com/s/3wmcw0zgcmlog0v/0_ZELDA.zip?dl=1

Here's the complete project. Run "Main.bas", then use arrow keys to move the character around.
Edited 2020-08-09 22:08 by Atomizer_Zero
 
matherp
Guru

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

Here's the complete project. Run "Main.bas"

There is something confused in your code
SPRITE show LINK, PLAYERX, PLAYERY,SPRITECOPY
page copy SPRITECOPY,SPRITETILES,B


In this statement you are using a page number as a layer

layers are just used for collision detection. They are nothing to do with pages

You want the sprites to exist on PAGE 2. This means before any SPRITE command you need to be writing to PAGE 2 (PAGE WRITE 2). All the sprite layers then exist on PAGE 2.

The copy is copying page 2 to page 3 which seems to be completely strange as it doesn't affect what is seen at all. I would expect the copy to be from 2 to 1

Try

'DRAW BLACK BOX TOP OF SCREEN - temp until implemented proper.
Page write 2

box  0,0, mm.hres, 64, 0, RGB(1,1,1),RGB(1,1,1)

DO
page write spritecopy
SPRITE show LINK, PLAYERX, PLAYERY,SPRITECOPY
page copy SPRITECOPY,1,B

 KEYINPUT()
 PLAYERUPDATE()
 ROOMEDGEHIT()
LOOP

Edited 2020-08-10 00:26 by matherp
 
Atomizer_Zero
Senior Member

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

Ok, I have re-organised and renamed the CONST variables for pages, to make it easier to follow.

CONST OVERWORLD = 0 'PAGE 0 - BACKGROUND TILE DRAWING
CONST SPRITEPAGE = 1 'PAGE 1 - FOREGROND SPRITE DRAWING
CONST SPRITECOPYPAGE = 2 'PAGE 2 - DRAW TO THIS PAGE, THEN COPY TO SPRITEPAGE
CONST SPRITETILESET = 3 'PAGE 3 - SPRITE TILESET
CONST OVERWORLDTILESET = 4 'PAGE 4 - OVERWORLD TILESET


I WRITE the png files to their respective pages
'WRITE TILESET TO PAGE
PAGE WRITE OVERWORLDTILESET : CLS
LOAD PNG "ZELDAOW.PNG"
IMAGE RESIZE_FAST 0,0, 96, 56, 0, 0, 96*2, 56*2, OVERWORLDTILESET

PAGE WRITE SPRITETILESET : CLS
LOAD PNG "SPRITES.PNG" ,0,0,15
IMAGE RESIZE_FAST 0,0, 96, 80, 0, 0, 96*2, 80*2, SPRITETILESET


Then I SPRITE READ LINK, 32, 0, 16, 16 (LINK is SPRITE 1)

I draw the map using PAGE WRITE OVERWORLD, then do drawing routine

Now, we enter the DO LOOP
DO
PAGE WRITE SPRITECOPYPAGE
SPRITE SHOW LINK, PLAYERX, PLAYERY, SPRITECOPYPAGE
PAGE COPY SPRITECOPYPAGE, SPRITEPAGE,B

KEYINPUT()
PLAYERUPDATE()
ROOMEDGEHIT()
LOOP


And yeh, this works perfectly. Thanks!

I have another question though. Can I copy multiple pages to SPRITEPAGE? for example, can I have on screen HUD/GUI stuff on say, page 8 (an unused page), then after the PAGE COPY SPRITECOPYPAGE, SPRITEPAGE,B, can I do PAGE COPY 8, SPRITEPAGE,B?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10580
Posted: 04:55pm 09 Aug 2020
Copy link to clipboard 
Print this post

You are still using a page number as a layer number. See the info post I've just done
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 05:13pm 09 Aug 2020
Copy link to clipboard 
Print this post

Oh yeh, sorry. I forgot to change that.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 02:23am 10 Aug 2020
Copy link to clipboard 
Print this post

Yeah I finally figured this stuff with the transparencies out after seeing the new version of the graphics programming manual. It does seem quite slow though, particularly on modes 1 and 2.  I made a little Amiga Bouncing Ball demo (drawing the ball instead of using sprites since I don't have the sprite data yet to do the rotation on the ball). It was HORRIBLY slow in mode 1,12.  2,12 was ok, 3,12 was fine.  

I draw the background on layer 0 (page 2), the Shadow and Ball on page 3,  and I then page copying 3 to 0. Seems to work.
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025