Jump to content

Photo

player editor


62 replies to this topic

#51 Schlortt OFFLINE  

Schlortt

    Combat Commando

  • 8 posts

Posted Sun Oct 15, 2017 5:58 PM

Here is an example of what Irgendwer is referring to.  In the first picture, you can see the car is ahead of the tires.  This is because the position of the car was updated, then the DLI kicks off before the tire position is updated to match the car. 

 

In the second picture, there are missing interrupts (red circles) and it looks like some of the tires weren't drawn.

Attached Thumbnails

  • timing.png
  • interrupts.png

Edited by Schlortt, Sun Oct 15, 2017 6:07 PM.


#52 8bit-Dude OFFLINE  

8bit-Dude

    Star Raider

  • 54 posts
  • Location:Kyoto, Japan

Posted Tue Oct 17, 2017 9:19 AM

Hey Guyz,

 

I have another question: when exporting ASM code from Atari Interlace Studio, I can compile it with MADS and call from CC65 with a JSR.

I have created some background GFX in mode G11, with no raster, no DLI, really simple case.

However, after initialzing the G11 graphics, the sprites don't show up properly.

 

Would you mind having a quick look at the ASM and C code, and let me know what I am doing wrong?

Cheers!!!

// Atari Interlaced Studio

buf0	= $6010

gtictl	= $d01b
skctl	= $d20f
portb	= $d301

dmactl	= $d400
dlptr	= $d402
wsync	= $d40a
vcount	= $d40b
nmien	= $d40e
nmist	= $d40f

/*-------------------------------------------------------------------------------------------------*/

	org $80

regA	.ds 1
regX	.ds 1
regY	.ds 1
cnt	.ds 1

/*-------------------------------------------------------------------------------------------------*/

	.get 'g11.dat',-9		; palette

	org buf0
	ins 'g11.dat',0,8000

/*-------------------------------------------------------------------------------------------------*/

	.align	$100

	dlist0:	dta d'ppp'
		dta $4f,a(buf0)
		:101 dta $f
		dta $4f,0,h(buf0+$1000)
		:89 dta $f
		dta $41,a(dlist0)

/*-------------------------------------------------------------------------------------------------*/

.proc StartG11
	lda:cmp:req 20

	mva	#$00	nmien
	mva	#$fe	portb

	mwa	#dlist0	dlptr
	mwa	#NMI	$fffa
	mva	#$c0	nmien

	lda:rne vcount
	rts				; exit
.endp

.proc StopG11
	lda:rne vcount

	mva	#$ff	portb
	mva	#$40	nmien
	
	rts
.endp

/*-------------------------------------------------------------------------------------------------*/

NMI	
	bit nmist
	bpl vbl

vdli equ *-2

vbl	sta nmist
	phr

	;mva #$22 dmactl
	mva #62 dmactl

	;mva #$c0 gtictl		; graphics 11
	mva #241 gtictl		; graphics 11

	plr
	rti

#include <cc65.h>
#include <conio.h>
#include <peekpoke.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#define PLAYERS (4)
#define FRAMES (16)
#define HEIGHT (13)

#define PMGMem (0x4000)

// sprites data
unsigned int PMGBase[5] = {PMGMem+1024, PMGMem+1280, PMGMem+1536, PMGMem+1792, PMGMem+768};
unsigned int PMGAddr[5] = {PMGMem+1024, PMGMem+1280, PMGMem+1536, PMGMem+1792, PMGMem+768};
unsigned char PMColor[5] = {0x72, 0x22, 0xb6, 0xec, 0x00};
unsigned char xpos[4];
unsigned char ypos[4];
unsigned char frame[4];

#define FRAMES (16)
#define HEIGHT (13)

const unsigned char BODY[FRAMES][HEIGHT] =
{ { 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3e, 0x32, 0x32, 0x3e, 0x3c, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x04, 0x1e, 0x3a, 0x32, 0x36, 0x3e, 0x18, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x04, 0x0e, 0x1a, 0x34, 0x38, 0x38, 0x30, 0x10, 0x00, 0x00 },
  { 0x00, 0x00, 0x18, 0x1c, 0x14, 0x28, 0x38, 0x38, 0x38, 0x30, 0x10, 0x00, 0x00 },
  { 0x00, 0x00, 0x10, 0x38, 0x28, 0x28, 0x38, 0x38, 0x38, 0x38, 0x38, 0x00, 0x00 },
  { 0x00, 0x00, 0x30, 0x70, 0x50, 0x28, 0x38, 0x38, 0x38, 0x18, 0x10, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x20, 0x70, 0x58, 0x2c, 0x1c, 0x1c, 0x0c, 0x08, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x20, 0x78, 0x5c, 0x4c, 0x6c, 0x7c, 0x18, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00, 0x3c, 0x7c, 0x4c, 0x4c, 0x7c, 0x3c, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00, 0x18, 0x7c, 0x6c, 0x4c, 0x5c, 0x78, 0x20, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x08, 0x0c, 0x1c, 0x1c, 0x2c, 0x58, 0x70, 0x20, 0x00, 0x00 },
  { 0x00, 0x00, 0x08, 0x0c, 0x1c, 0x1c, 0x1c, 0x14, 0x28, 0x38, 0x18, 0x00, 0x00 },
  { 0x00, 0x00, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x14, 0x14, 0x1c, 0x08, 0x00, 0x00 },
  { 0x00, 0x00, 0x08, 0x18, 0x1c, 0x1c, 0x1c, 0x14, 0x0a, 0x0e, 0x0c, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x10, 0x30, 0x38, 0x38, 0x34, 0x1a, 0x0e, 0x04, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x18, 0x3e, 0x36, 0x32, 0x3a, 0x1e, 0x04, 0x00, 0x00, 0x00 } };

const unsigned char TIRES[FRAMES][HEIGHT] =
{ { 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x28, 0x28, 0x00 },
  { 0x00, 0x00, 0x08, 0x28, 0x20, 0x04, 0x0c, 0x08, 0x00, 0x04, 0x14, 0x10, 0x00 },
  { 0x00, 0x00, 0x00, 0x18, 0x10, 0x04, 0x4a, 0x46, 0x00, 0x08, 0x08, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x20, 0x28, 0x14, 0x44, 0x40, 0x00, 0x08, 0x08, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x00, 0x54, 0x54, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x08, 0x28, 0x50, 0x44, 0x04, 0x00, 0x20, 0x20, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x18, 0x08, 0x20, 0x52, 0x62, 0x00, 0x10, 0x10, 0x00, 0x00 },
  { 0x00, 0x00, 0x10, 0x14, 0x04, 0x20, 0x30, 0x10, 0x00, 0x20, 0x28, 0x08, 0x00 },
  { 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x14, 0x14, 0x00 },
  { 0x00, 0x00, 0x08, 0x28, 0x20, 0x00, 0x10, 0x30, 0x20, 0x04, 0x14, 0x10, 0x00 },
  { 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x62, 0x52, 0x20, 0x08, 0x18, 0x00, 0x00 },
  { 0x00, 0x00, 0x10, 0x10, 0x00, 0x02, 0x22, 0x28, 0x14, 0x04, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x2a, 0x2a, 0x00, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x04, 0x04, 0x00, 0x20, 0x22, 0x0a, 0x14, 0x10, 0x00, 0x00, 0x00 },
  { 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x46, 0x4a, 0x04, 0x10, 0x18, 0x00, 0x00 },
  { 0x00, 0x10, 0x14, 0x04, 0x00, 0x08, 0x0c, 0x04, 0x20, 0x28, 0x08, 0x00, 0x00 } };  

clock_t tFPS;
unsigned long f;
void DrawFPS()
{	
	// Calculate stats
    unsigned int fps;
	tFPS = clock() - tFPS;
    fps = (f*CLK_TCK)/tFPS;
	tFPS = clock();	

	// Output stats
    gotoxy(0,0);
    printf("FPS: %u", fps);
}

unsigned char i;

void InitSprites(void)
{
	POKE(54279, PMGMem>>8); // Tell ANTIC where the PM data is located
	POKE(53277, 2+1);       // Tell GTIA to enable players + missile	
	POKE(623, 32+16+1);		// Tricolor players + enable fifth player + priority
	POKE(559, 32+16+8+4+2); // DMA Screen + Enable P/M + DMA Players + DMA Missiles + Single resolution
    for (i=0; i<4; i++) {
        bzero(PMGAddr[i],0x100);   // Clear Player memory
        POKE(704+i, PMColor[i]);   // Set Player colors
    }
    bzero(PMGAddr[4],0x100);  // Clear Missile memory
	POKE(711, PMColor[4]);	  // Set Player color
}

void ShowSprites(void)
{ 
    clock_t timer = clock();
    unsigned int angle = 0;
    tFPS = clock();	
	while (!kbhit()) {   
        // Update body position
        //if (clock()>timer) {
        //    timer = clock();
            angle++;
            for (i=0; i<PLAYERS; i++) {
                xpos[i] = 128+cc65_cos((angle+i*90)%360)/6;
                ypos[i] = 128+cc65_sin((angle+i*90)%360)/4;
                frame[i] = ((12-(angle+(i+1)*90))%360)/23;
                POKE(53248+i, xpos[i]);
                bzero(PMGAddr[i], HEIGHT);        
                PMGAddr[i] = PMGBase[i]+ypos[i];
                memcpy(PMGAddr[i], BODY[frame[i]], HEIGHT);
            }       
        //}
        
        // Flicker TIRES
        i = f%PLAYERS;
        bzero(PMGAddr[4], HEIGHT);
        PMGAddr[4] = PMGBase[4]+ypos[i];
        POKE(53252, xpos[i]+6);
        POKE(53253, xpos[i]+4);
        POKE(53254, xpos[i]+2);
        POKE(53255, xpos[i]+0);
        memcpy(PMGAddr[4], TIRES[frame[i]], HEIGHT);          

        // Next Frame
        if (f > 60) { DrawFPS(); f=0; }
        f++;
    }
}
/*
** Hello world program using cc65.
*/

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <unistd.h>
#include "sprites1.h"

/*****************************************************************************/
/*                                   Code                                    */
/*****************************************************************************/

int main (void)
{       
    // Start CIN
    __asm__("jsr $80CA"); 
    
	// Start Sprites
    InitSprites();
    ShowSprites();

	// Stop G11
	__asm__("jsr $80F9");	
    
    // Done
    return EXIT_SUCCESS;
}

Attached Files



#53 Schlortt OFFLINE  

Schlortt

    Combat Commando

  • 8 posts

Posted Tue Oct 17, 2017 12:41 PM

Try using the hardware registers for PM color since you are using a GTIA mode.

POKE(704+i, PMColor[i]); // Set Player colors

should be

POKE(53266+i, PMColor[i]); // Set Player colors



#54 Wrathchild OFFLINE  

Wrathchild

    Stargunner

  • 1,866 posts
  • Location:Reading, UK.

Posted Tue Oct 17, 2017 12:42 PM

The xex crashes due to the FPS output as the OS is disabled at this point



#55 8bit-Dude OFFLINE  

8bit-Dude

    Star Raider

  • 54 posts
  • Location:Kyoto, Japan

Posted Tue Oct 17, 2017 9:38 PM

Try using the hardware registers for PM color since you are using a GTIA mode.

POKE(704+i, PMColor[i]); // Set Player colors

should be

POKE(53266+i, PMColor[i]); // Set Player colors

Awesome, that worked!!!!



#56 8bit-Dude OFFLINE  

8bit-Dude

    Star Raider

  • 54 posts
  • Location:Kyoto, Japan

Posted Tue Oct 17, 2017 9:39 PM

The xex crashes due to the FPS output as the OS is disabled at this point

Well spotted buddy!!



#57 8bit-Dude OFFLINE  

8bit-Dude

    Star Raider

  • 54 posts
  • Location:Kyoto, Japan

Posted Wed Oct 18, 2017 2:25 AM

So, back with more questions!

I have integrated my sprites animation with a CIN background image as shown here:

 

sprites.jpg

 

I still have a couple of issues:

 

    (1) I set the colour of P4 (tires) with:  POKE(53273, PMColor[4]);   // Set Player colors

          However, the colour flickers based on P0-P3...

 

    (2) I have an issue with this line of code in the asm file:  mva #$fe portb

          This functions is used by CIN to disable to ROM, or something like that, but the functions clock() and cgect() in cc65 stop working.
          If I comment this line I can use clock() and cget(), but then the CIN gfx do not appear.

 

Could you guyz give me again some advice?? Thx a lot in advance!!!!

Tony

Attached Thumbnails

  • sprites.jpg

Attached Files



#58 Schlortt OFFLINE  

Schlortt

    Combat Commando

  • 8 posts

Posted Wed Oct 18, 2017 8:23 AM

The multicolored tires is a sign that gprior (623)/ prior (53275) are not set.  Enabling the 5th player (bit 4)  is what allows you to set the missiles to a single color.  I see in your code, you set 623.  623 is a shadow register for hardware register 53275.  Shadow registers get copied to hardware registers by the OS routines during the vertical blank as I understand it.  Additionally, the clock memlocs (18,19,20) are also managed by the OS routines so that should explain the clock not working.  I think this explains what is going here, but whether you use the OS or write custom routines to meet your specific needs is up to you.



#59 8bit-Dude OFFLINE  

8bit-Dude

    Star Raider

  • 54 posts
  • Location:Kyoto, Japan

Posted Wed Oct 18, 2017 9:53 AM

The multicolored tires is a sign that gprior (623)/ prior (53275) are not set.  Enabling the 5th player (bit 4)  is what allows you to set the missiles to a single color.  I see in your code, you set 623.  623 is a shadow register for hardware register 53275.  Shadow registers get copied to hardware registers by the OS routines during the vertical blank as I understand it.  Additionally, the clock memlocs (18,19,20) are also managed by the OS routines so that should explain the clock not working.  I think this explains what is going here, but whether you use the OS or write custom routines to meet your specific needs is up to you.

Hey Schlortt

I will try to figure out the tire issue based on your remarks.

The OS stuff is much more problematic for me. I do not want to disable it, but the CIN code I obtained from Atari Interlaced Studio seems to require setting the OS off.

By looking at the ASM code, could you tell me why CIN needs it, and if there is a way to avoid switching off the OS.



#60 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,207 posts
  • Location:Germany

Posted Wed Oct 18, 2017 12:22 PM

I have integrated my sprites animation with a CIN background image as shown here:

 

Only a general remark: If you like to have at least somewhat acceptance for your game in PAL-land do not use CIN or other interlaced background graphics.

They flicker like hell and it's a complete different story to interlaced PMGs as the area is much bigger.

The issue may not be apparent one most LCD monitors but it is there.
 



#61 Philsan OFFLINE  

Philsan

    River Patroller

  • 3,389 posts
  • New Orleans Saints Super Bowl XLIV Champions
  • Location:Switzerland

Posted Wed Oct 18, 2017 1:40 PM

I agree. Please don't use interlaced modes.



#62 CharlieChaplin OFFLINE  

CharlieChaplin

    River Patroller

  • 2,553 posts

Posted Wed Oct 18, 2017 1:47 PM

How about mode 15 PAL blending ?!?



#63 Philsan OFFLINE  

Philsan

    River Patroller

  • 3,389 posts
  • New Orleans Saints Super Bowl XLIV Champions
  • Location:Switzerland

Posted Wed Oct 18, 2017 2:07 PM

Aren't the cars too small to be seen with mode 15 pal blending?






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users