News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_fgbrain

Hardware sprites multiplexing

Started by fgbrain, 16:00, 01 June 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fgbrain

Hi!

I try to understand how to multiplex sprites on the Plus.
The wiki page is not very clear on this subject...

Any help and sources will greatly be appreciated.

_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

andycadley

Changes to the hardware sprites are reflected immediately, so the principle is to set a sprite to display, wait till after it has drawn and then quickly reload the registers for a location further down the screen.

The difficulty comes largely from the problem that changing the image of a sprite is quite a large operation, so it's tricky unless you can reuse the same image.

It's also possible, through careful timing, to split sprites in half vertically, which is occasionally effective if a bit tricky for general purpose use.

TFM

Quote from: fgbrain on 16:00, 01 June 15
Hi!

I try to understand how to multiplex sprites on the Plus.
The wiki page is not very clear on this subject...

Any help and sources will greatly be appreciated.


If you want the same sprite in at different Y coordinates it's easy. Just change the Y of the sprite at the right time. In X I never tried.

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: TFM on 17:04, 01 June 15

If you want the same sprite in at different Y coordinates it's easy. Just change the Y of the sprite at the right time. In X I never tried.

TFM is correct.

If you want to re-use the same sprite you can change it's Y position at a point *after* it is displayed.

Want to use sprite 1 at line 16 and 200?

Set position before line 16.

Then set position a second time after line (16+16 - no y mag).

Repeat this every frame.

If you change the X position then sprite will be cut. you *can* repeat the same sprite across the screen, but it's not worth it because you must do this:

set x, wait, set x again, wait (repeat for all lines).

Too much processor time.


If you want to have more than 16 images then you'll need to download data into the sprite, but that can take 20 scanlines.

So now you need to do this:

set y.
interrupt after sprite displayed.
download data into sprite.
set new y
wait until sprite displayed
download data into sprite

and repeat...

too much time :(

EDIT: If you want to re-use sprites (same image), then you also need to sort the sprites by y and manage the interrupts to set their positions.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

TFM

Yepp, that's exactly how to do it. Arnie is better than every handbook!  ;)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

fgbrain


Thanks for all replies!


The idea is to have a small sprite like a bullet/rocket copied for say 15 times down the screen..
but I must figure a way to manage the exact timings.


I will do some tests and come back!
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

Ast

#6
Hi FgBrain,


the most easy way to display hardware sprite multiplexing is using the Pri (Programmable Raster Interrupt) register.
You'll have to precise which line to wait, then to plot your sprite x,y...
Do that each rasterline you want... That's what i used in Synergy Demo and X-Mas 2008 one.


It's very easy to do ! if you need any example, just ask me..


NdEdit : Another technique will be to do a splitscreen using crtc registers... All sprites displayed in the first split will be copied in the second split and so on.....

Bye!
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

#7
Here is the result of what i tell you..... The Sprite displays a square copied 3 times in your screen. You can do more of course!


;
; Sprites Multiplexing for FgBrain
; Ast/iMPACT - Amstrad Plus/Gx4000
; Orgams Assembler code
;
      ORG #A000
      ENT $
sprite0 = #4000         ; Sprite 0 adress
sprz  = #6004           ; zoom x,y Sprite 0
sprx  = #6000           ; Sprite 0 x
spry  = #6002           ; Sprite 0 y




sprink1 = #6422         ; sprite color 1
ink0  = #6400           ; ink 0
border = #6420          ; border
pri   = #6800           ; Programmable raster interrupt
;         DI
          LD   HL,#C9FB ; Kill interruption
          LD   (#38),HL
          LD   E,17     ; Unlock Asic
          LD   HL,tbasic
          LD   B,#BC
loop      LD   A,(HL)
          OUT  (C),A
          INC  HL
          DEC  E
          JR   NZ,loop
;
          LD   BC,#7FB8 ; Page i/o on         
          OUT  (C),C
;
          LD   HL,sprdata ; copy sprite data
          LD   DE,sprite0 ; in i/o Page
          LD   BC,16*16
          LDIR
;
          LD   HL,#0FFF ; full white
          LD   (sprink1),HL ; sprite color 1 will be white
;
          LD   HL,#00   ; full black
          LD   (ink0),HL ; put ink 0 & border
          LD   (border),HL
;
          LD   A,%1001  ; put sprite size
          LD   (sprz),A ; x*2/Y*1
;
          LD   BC,#7FA0 ; page asic i/o off
          OUT  (C),C
          EI
;
          LD   B,#F5
sync      IN   A,(C)
          RRA
          JR   NC,sync
;
          LD   BC,#7FB8 ; page asic i/o on
          OUT  (C),C
;
          LD   HL,0     ; define spr0 x,y (1st position)
          LD   (sprx),HL
          LD   A,1
          LD   (spry),A
;
          LD   A,15     ; wait for rasterline 2
          LD   (pri),A
          HALT
      FILL 32,0
          LD   HL,16    ; define spr0 x,y (2nd position)
          LD   (sprx),HL
          LD   A,17
          LD   (spry),A
;
          LD   A,31     ; wait for rasterline 3
          LD   (pri),A
          HALT
      FILL 32,0
;
          LD   HL,0     ; define spr 0,y (3th position)
          LD   (sprx),HL
          LD   A,33
          LD   (spry),A
;
          LD   BC,#7FA0 ; page asic i/o off
          OUT  (C),C
          JR   main
tbasic BYTE 255,0,255,119,179
      BYTE 81,168,212,98,57,156
      BYTE 70,43,21,138,205,238
;
; Sprite Data definition (Little Square)
;
sprdata
      BYTE 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
      14 ** [
      BYTE 1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1
]
      BYTE 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
;
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Powered by SMFPacks Menu Editor Mod