For those who already see my messages, you know that this code is made based on TNIASM, a cross-compiler you can find in the Internet, used for example in the GameBoy homebrew scene for years.
I'm not gonna talk about the video settings, but about sprites.
The following listing doesn't move or change color a bunch of sprites... let's keep it simple and just display sprites on screen. In the video, I'm showing the evolution of this listing starting from 1 sprite to 3,5 and then 7 sprites. With 5 sprites, because the video chip doesn't show more than 4 sprites in a row, I've added a sprites flickering effect based the principle of a circular buffer with the sprites priority table. Other technics like simply swap to the highest priority the non showing sprite might be fast but raise the question why if another sprite (that we are not aware of) does also need to get a higher priority at the same time? That's why I'm using the solution shown here.
The table of sprite priorities is initialized with the numbers 0 to nbr_sprites-1, so if there is 5 sprites to show then the table of priorities is [0,1,2,3,4]. When the flickering effect is needed, the first sprite to be the 5th sprite in a row is retreived from the video register and used as a starting point for the circular buffer. For example, if always the 5th sprite condition occurs for a 5 priorities table, you get the following tables of priorities during time : [0,1,2,3,4] -> [4,0,1,2,3] -> [3,4,0,1,2] -> [2,3,4,0,1] -> [1,2,3,4,0] and so on. This makes all the 5 sprites flickering on screen. With the "swap only the 5th sprite to the highest priority" solution, only 2 sprites are flickering on screen, which seems to be a pretty good solution, but deny the possibility if there is a 6th sprite or even a 7th sprite. The flickering effect with 7 sprites, in this sample program, acts as follow : [0,1,2,3,4,5,6] -> [4,5,6,0,1,2,3] -> [1,2,3,4,5,6,0] -> [5,6,0,1,2,3,4] -> [2,3,4,5,6,0,1] -> [6,0,1,2,3,4,5] -> [3,4,5,6,0,1,2] and so on. Well, it should be this sequence, I can't be sure if the emulator you are using will gives you this sequence of sprites order and so this sprites flickering effect.
As usual, if you appreciate this program, if you find it useful, please consider voting and/or leave a message.
; Colecovision - Sprites Demo ; by Daniel Bienvenu, 2010 NBR_SPRITES: equ 7 fname "7sprites.rom" cpu Z80 org $8000 dw $aa55,SprAttrib,$7000,0,0,Start dw 0,0,0,0,0,0,0,0,0,0 ret Nmi: ; Display Sprite(s) ld a,NBR_SPRITES call $1fc4 ; WR_SPR_NM_TBL ld a,$d0 out ($be),a ; Get Video Status call $1fdc ; READ_REGISTER bit 6,a jr z,DoNothing and $1f ; keep only 5bits = sprite# ld e,a ld d,0 ld hl,($8004) push hl add hl,de ld c,(hl) ; Get corresponding Sprite entry pop hl ld a,NBR_SPRITES ld b,a Reordering1: ld (hl),c inc hl inc c cp c jr nz,Reordering2 ld c,0 Reordering2: djnz Reordering1 DoNothing: retn Start: call $1f85 ; MODE_1 call $1fd6 ; TURN_OFF_SOUND ; Clear VRAM ld hl,0 ld de,$4000 xor a call $1f82 ; FILL_VRAM ; Load Sprite Pattern ld de,$3800 ld hl,HappyAlienBugFace ld bc,32 call $1fdf ; WRITE_VRAM ; Init. Sprites Order ld a,NBR_SPRITES call $1fc1 ; INIT_SPR_ORDER ; Turn On Display + Enable NMI ld bc,$01e2 call $1fd9 ; WRITE_REGISTER TheEnd: jp TheEnd SprAttrib: db 82, 24,0,13 ; Y=82, X= 24, Pattern#0, Color=13 db 84, 56,0, 8 ; Y=84, X= 56, Pattern#0, Color=8 db 86, 88,0, 9 ; Y=86, X= 88, Pattern#0, Color=9 db 88,120,0,10 ; Y=88, X=120, Pattern#0, Color=10 db 90,152,0, 3 ; Y=90, X=152, Pattern#0, Color=3 db 92,184,0, 7 ; Y=92, X=184, Pattern#0, Color=7 db 94,216,0, 4 ; Y=94, X=216, Pattern#0, Color=4 HappyAlienBugFace: db %00011000 db %01100100 db %11000011 db %00001111 db %00011001 db %00110000 db %00110110 db %01111111 db %01111111 db %01111111 db %01110000 db %00110000 db %00111000 db %00011110 db %00001111 db %00000011 db %00001100 db %00010010 db %11100011 db %11111001 db %11001100 db %10000110 db %10110110 db %11111111 db %11111111 db %11111111 db %00000111 db %00000110 db %00001110 db %00111100 db %11111000 db %11100000
Edited by newcoleco, Sat Aug 28, 2010 11:56 AM.















