Author Topic: Animating sprites on the Plus  (Read 1195 times)

0 Members and 1 Guest are viewing this topic.

Offline Skunkfish

  • Supporter
  • 6128 Plus
  • *
  • Posts: 542
  • Country: gb
  • Editor of Colour Personal Computing
    • CPCSTORE.CO.UK - Dedicated to the Amstrad CPC
  • Liked: 401
  • Likes Given: 1007
Animating sprites on the Plus
« on: 16:11, 19 January 17 »
Is it possible to animate hardware sprites on the Plus without using multiple sprites?

If it is achievable, is it possible at a decent speed?
An expanding array of hardware available at www.cpcstore.co.uk (and issue 3 of CPC Fanzine!)

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 874
  • Country: fr
    • urban exploration
  • Liked: 1173
  • Likes Given: 709
Re: Animating sprites on the Plus
« Reply #1 on: 16:43, 19 January 17 »



it's possible but you will need a huge amount of memory (who cares if you make a cartridge?)


there is many optimisations like only poke the differences in your animation, use stack to push values and keep redondant values in registers


if you have many sprites to update each frame, you will also need a clever manager to avoid screen refresh artefact (if you know you need kind of 20 raster lines to upate, then you can update when you are 20 lines before the sprite, or right after it. You can either compute the value or use dma-list)
use RASM, the best assembler ever made :p

I will survive

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 908
  • Liked: 442
  • Likes Given: 73
Re: Animating sprites on the Plus
« Reply #2 on: 21:40, 19 January 17 »

There are other tricks too. Maybe you don't need to update at 50fps and can arrange for things to happen over multiple frames. Or maybe your sprite animations cycle in such a way that you can avoid two having the same frame at any one time, then dynamically assign a hw sprite to an object on a frame-by-frame basis.


JSW+ manages 25fps with updates to all 16 sprites. It's having to decompress them on the fly (128K isn't enough and RAM paging doesn't play well with the ASIC register paging), so it's partially cheating - the "walking willy" life animation only decompresses one frame then blats it across the rest and only half the nasties move on each frame. It works pretty well, I found, but I'd probably go cart for anything with lots of sprites in future as it makes life a lot easier (especially given there is no real cost to a 512K cart these days!)

Offline Skunkfish

  • Supporter
  • 6128 Plus
  • *
  • Posts: 542
  • Country: gb
  • Editor of Colour Personal Computing
    • CPCSTORE.CO.UK - Dedicated to the Amstrad CPC
  • Liked: 401
  • Likes Given: 1007
Re: Animating sprites on the Plus
« Reply #3 on: 23:31, 19 January 17 »
Thanks for tips!

And I'm assuming there's no shortcut for rotating/mirroring sprites?
An expanding array of hardware available at www.cpcstore.co.uk (and issue 3 of CPC Fanzine!)

Offline fgbrain

  • CPC6128
  • ****
  • Posts: 238
  • Country: gr
    • index.php?action=treasury
    • Chaos CPC Homepage
  • Liked: 137
  • Likes Given: 310
Re: Animating sprites on the Plus
« Reply #4 on: 14:11, 07 October 18 »
sorry to bring this old thread back...

I thought of an easy routine to vertically flip a hardware spite..
Requires a copy of the sprite in RAM to work.


Code: [Select]
;  DE = sprite in ASIC ram
;  HL = sprite sprite in RAM
;
; sets sprite  upsidedown
;
ld bc,16*15:add hl,bc  ; HL = last Y line
ld a,32:   ; will use A = 32 to reset C 15 times
ld c,16:ldir ;line 0
ld c,a:sbc hl,bc:rr c:ldir ;line 1  ;  C = 32 to  move HL to previous line Y-1 and go on then   C = 16
ld c,a:sbc hl,bc:rr c:ldir ;line 2
ld c,a:sbc hl,bc:rr c:ldir ;line 3
ld c,a:sbc hl,bc:rr c:ldir ;line 4
ld c,a:sbc hl,bc:rr c:ldir ;line 5
ld c,a:sbc hl,bc:rr c:ldir ;line 6
ld c,a:sbc hl,bc:rr c:ldir ;line 7
ld c,a:sbc hl,bc:rr c:ldir ;line 8
ld c,a:sbc hl,bc:rr c:ldir ;line 9
ld c,a:sbc hl,bc:rr c:ldir ;line 10
ld c,a:sbc hl,bc:rr c:ldir ;line 11
ld c,a:sbc hl,bc:rr c:ldir ;line 12
ld c,a:sbc hl,bc:rr c:ldir ;line 13
ld c,a:sbc hl,bc:rr c:ldir ;line 14
ld c,a:sbc hl,bc:rr c:ldir ;line 15


You can of course unroll the LDIR command and use 16x LDIs instead...
_____

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.