English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 03 March 2023, 14:38   #1
gameblabla
Registered User
 
Join Date: Feb 2023
Location: France
Posts: 3
Displaying a sprite on the Amiga at Y=>256

Hello !
Managed to get a sprite on screen following Photon's tutorial.
The problem is that he only ever moved the sprites horizontally.
I eventually managed to make them move on the vertical axis as well.
Code:
smile_sprite_ptr[0] = 0x2C + y;
smile_sprite_ptr[1] = 0x40 + x;
smile_sprite_ptr[2] = 0x3C + y + 16;
However, if smile_sprite_ptr[2] (Y) is superior to 256, the sprite ends up being a glitchy mess right below it.
Apparently i have to set the 9th bit in SPR0CTL to make this work (*SPR0CTL |= 0x0100; ) but i had no luck with that.
Here's the code in full :
Code:
#include <clib/exec_protos.h>
#include <graphics/gfxbase.h>
#include <exec/types.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/blit.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
volatile uint16_t* const DMACONR     = (uint16_t* const) 0xDFF002;
volatile uint32_t* const VPOS32      = (uint32_t* const) 0xDFF004;
volatile uint16_t* const VPOSR       = (uint16_t* const) 0xDFF004;
volatile uint8_t*  const VPOSR_LOW   = (uint8_t*  const) 0xDFF005;
volatile uint16_t* const VPOSHR      = (uint16_t* const) 0xDFF006;
volatile uint8_t*  const VPOSHR_HIGH = (uint8_t*  const) 0xDFF006;
volatile uint8_t*  const VPOSHR_LOW  = (uint8_t*  const) 0xDFF007;
volatile uint16_t* const INTENAR     = (uint16_t* const) 0xDFF01C;
volatile uint32_t* const COP1LC32    = (uint32_t* const) 0xDFF080;
volatile uint16_t* const COP1LCH     = (uint16_t* const) 0xDFF080;
volatile uint16_t* const COP1LCL     = (uint16_t* const) 0xDFF082;
volatile uint16_t* const COP2LCH     = (uint16_t* const) 0xDFF084;
volatile uint16_t* const COP2LCL     = (uint16_t* const) 0xDFF086;
volatile uint16_t* const DMACONW     = (uint16_t* const) 0xDFF096;
volatile uint16_t* const INTENAW     = (uint16_t* const) 0xDFF09A;
volatile uint16_t* const INTREQW     = (uint16_t* const) 0xDFF09C;
volatile uint8_t*  const CIAA_PRA    = (uint8_t* const ) 0xBFE001;
uint8_t*              screen_ptr =   0;
uint8_t*              smile_sprite_ptr = 0;
uint16_t*             copper_list = 0;
uint16_t*             copper_list_end = 0;
const uint16_t SMILE_SPRITE[] = {
    0x2C40,0x3C00, // Vstart.b,Hstart/2.b,Vstop.b,%A0000SEH
        
    0x07C0,0x0000, // dc.w %     *****      ,%                
    0x1FF0,0x0000, // dc.w %   *********    ,%                
    0x3FF8,0x0000, // dc.w %  ***********   ,%                
    0x7FFC,0x0000, // dc.w % *************  ,%                
    0x67CC,0x1830, // dc.w % **  *****  **  ,%   **     **    
    0xE7CE,0x1830, // dc.w %***  *****  *** ,%   **     **    
    0xFFFE,0x0000, // dc.w %*************** ,%                
    0xFFFE,0x0000, // dc.w %*************** ,%                
    0xFFFE,0x2008, // dc.w %*************** ,%  *         *   
    0xFFFE,0x1830, // dc.w %*************** ,%   **     **    
    0x7FFC,0x07C0, // dc.w % *************  ,%     *****      
    0x7FFC,0x0000, // dc.w % *************  ,%                
    0x3FF8,0x0000, // dc.w %  ***********   ,%                
    0x1FF0,0x0000, // dc.w %   *********    ,%                
    0x07C0,0x0000, // dc.w %     *****      ,%                
    0x0000,0x0000, // dc.w %                ,%                
    0,0
};

const uint16_t NULL_SPRITE[] = {
    0x2a20,0x2b00,
    0,0,
    0,0
};

const uint16_t COPPER_LIST_BEGIN[] = {
//Copper:
    0x1fc,0, // slow fetch mode, AGA compatibility
    0x100,0x0200,
    0x8e,0x2c81,
    0x90,0x2cc1,
    0x92,0x38,
    0x94,0xd0,
    0x108,0,
    0x10a,0,
    0x102,0,
    0x1a2,0xe22,
    0x1a4,0xff0,
    0x1a6,0xfff
};

const uint16_t SPR_P[] = {
//SprP:
    0x120, 0x0000, // Sprite 0 SMILE_SPRITE_HIGH (value is defined later)
    0x122, 0x0000, // Sprite 0 SMILE_SPRITE_LOW
        
    0x124, 0x0000, // Sprite 1 NULL_SPRITE_HIGH
    0x126, 0x0000, // Sprite 1 NULL_SPRITE_LOW
        
    0x128, 0x0000, // Sprite 2 NULL_SPRITE_HIGH
    0x12a, 0x0000, // Sprite 2 NULL_SPRITE_LOW
        
    0x12c, 0x0000, // Sprite 3 NULL_SPRITE_HIGH
    0x12e, 0x0000, // Sprite 3 NULL_SPRITE_LOW
        
    0x130, 0x0000, // Sprite 4 NULL_SPRITE_HIGH
    0x132, 0x0000, // Sprite 4 NULL_SPRITE_LOW
        
    0x134, 0x0000, // Sprite 5 NULL_SPRITE_HIGH
    0x136, 0x0000, // Sprite 5 NULL_SPRITE_LOW
        
    0x138, 0x0000, // Sprite 6 NULL_SPRITE_HIGH
    0x13a, 0x0000, // Sprite 6 NULL_SPRITE_LOW
        
    0x13c, 0x0000, // Sprite 7 NULL_SPRITE_HIGH
    0x13e, 0x0000  // Sprite 7 NULL_SPRITE_LOW
};

const uint16_t COPPER_LIST_END[] = {
//CopBplP:
    0xe0, 0x0006, // Screen HIGH WORD 0x0006 default
    0xe2, 0x0000, // Screen LOW  WORD 0x0000 default
    0x100,0x1200, // BPLCON0
    0xffff,0xfffe // End Copper
};

void waitRaster(uint32_t value) {
    uint32_t mask = 0x1FF00;
    uint32_t maskedValue = (value << 8) & mask;
    
    while ((*VPOS32 & mask) != maskedValue);
}


volatile uint8_t *SPR0CTL = (volatile uint8_t *)0xDFF100;

uint16_t* smile_sprite_ptr_uword;

void createCopperList() {
    size_t size = sizeof(COPPER_LIST_BEGIN) +
                  sizeof(SPR_P) +
                  sizeof(COPPER_LIST_END) +
                  sizeof(SMILE_SPRITE) +
                  sizeof(NULL_SPRITE);
    
    uint16_t* helper = copper_list = (uint16_t*) AllocMem(size, MEMF_CHIP);
    
    smile_sprite_ptr_uword = (uint16_t*) AllocMem(sizeof(uint16_t) * 2, MEMF_CHIP);
    
    memcpy(helper, COPPER_LIST_BEGIN, sizeof(COPPER_LIST_BEGIN));
    helper += sizeof(COPPER_LIST_BEGIN) / sizeof(uint16_t);

    uint16_t* spr_p_ptr = helper;    
    memcpy(helper, SPR_P, sizeof(SPR_P));
    helper += sizeof(SPR_P) / sizeof(uint16_t);    
    
    copper_list_end = helper;
    memcpy(helper, COPPER_LIST_END, sizeof(COPPER_LIST_END));
    helper += sizeof(COPPER_LIST_END) / sizeof(uint16_t);
    
    smile_sprite_ptr = (uint8_t*) helper;
    memcpy(helper, SMILE_SPRITE, sizeof(SMILE_SPRITE));
    helper += sizeof(SMILE_SPRITE) / sizeof(uint16_t);
    
    uint16_t* null_sprite_ptr = helper;
    memcpy(helper, NULL_SPRITE, sizeof(NULL_SPRITE));
    
    smile_sprite_ptr_uword[0] = ((uint32_t) smile_sprite_ptr) & 0xFFFF;
    smile_sprite_ptr_uword[1] = ((uint32_t) smile_sprite_ptr) >> 16;
    
    uint16_t lo_null_sprite_ptr = ((uint32_t) null_sprite_ptr) & 0xFFFF;
    uint16_t hi_null_sprite_ptr = ((uint32_t) null_sprite_ptr) >> 16;
    
    spr_p_ptr[1] = smile_sprite_ptr_uword[1];
    spr_p_ptr[3] = smile_sprite_ptr_uword[0];

    for (int i = 0; i < 7; i++) {
        spr_p_ptr[5 + i * 4] = hi_null_sprite_ptr;
        spr_p_ptr[7 + i * 4] = lo_null_sprite_ptr;
    }
    
}

void destroyCopperList() {
    size_t size = sizeof(COPPER_LIST_BEGIN) +
                  sizeof(SPR_P) +
                  sizeof(COPPER_LIST_END) +
                  sizeof(SMILE_SPRITE) +
                  sizeof(NULL_SPRITE);
    
    FreeMem(copper_list, size);
}

void setCopperList(uint16_t* cl) {
    *COP1LCH =((uint32_t) cl) >> 16;
    *COP1LCL =((uint32_t) cl) & 0xFFFF;
}

void waitFrame() {
    do {
        while (*VPOSR_LOW & 1);
    } while (*VPOSHR_HIGH != 0x2a);
}

void waitFrame2() {
    while (*VPOSHR_HIGH != 0x2a );
}

bool leftClick() {
    return (*CIAA_PRA & (1 << 6)) == 0;
}

extern volatile struct Custom* custom;
volatile UWORD* const SPR0Y = (UWORD*)0xdff106;

int main(int argc, char** argv)
{   
    int16_t y = 0, x = 0;

    uint16_t old_INTENA = *INTENAR;
    uint16_t old_DMACON = *DMACONR;
        
    waitRaster(0x0138);
        
    *INTENAW = 0x7FFF; // Disable all bits in INTENA
    *INTREQW = 0x7FFF; // Idem
    *DMACONW = 0x7FFF; // Disable all bits in DMACON
    *DMACONW = 0x87E0; // Setting DMA channels

    createCopperList();
    setCopperList(copper_list);

    y = 184;
    x = 50;
    smile_sprite_ptr[0] = 0x2C + y;
    smile_sprite_ptr[1] = 0x40 + x;
    smile_sprite_ptr[2] = 0x3C + y + 16;
    // Set SPR0CTL bit if Y position is >= 256
    volatile UWORD* const SPR0CTL = (UWORD*)0xdff104;
    *SPR0CTL |= 0x0100;

    while (true)
    {
        waitFrame();
        waitFrame2();
    }
    destroyCopperList();

    return 0;
}
gameblabla is offline  
Old 03 March 2023, 16:41   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by gameblabla View Post
Code:
    smile_sprite_ptr[0] = 0x2C + y;
    smile_sprite_ptr[1] = 0x40 + x;
    smile_sprite_ptr[2] = 0x3C + y + 16;
    // Set SPR0CTL bit if Y position is >= 256
    volatile UWORD* const SPR0CTL = (UWORD*)0xdff104;
    *SPR0CTL |= 0x0100;
VSTOP8 is bit 2 of SPR0CTL. So there are multiple errors here. You set bit 8 of SPR0CTL, which is wrong and has no effect, as SPR0POS and SPR0CTL is updated by DMA. You have to set bit 2 in
smile_sprite_ptr[3]
.
phx is offline  
Old 05 March 2023, 20:52   #3
gameblabla
Registered User
 
Join Date: Feb 2023
Location: France
Posts: 3
Thanks phx, i was given code that fixed it further.
Code:
void Sprite_SetPos(int16_t sx, int16_t sy, int16_t sh, uint8_t* sp, bool attach)
{
	uint16_t h0 = 0x80 + sx;
	uint16_t v0 = 0x2c + sy;
	uint16_t v1 = v0 + sh;
	
	*sp++ = (uint8_t) v0;
	*sp++ = (uint8_t) h0 >> 1;
	
	*sp++ = (uint8_t) v1;
	
	h0 = h0 & 1;
	if (attach)
	{
		h0 |= 0x80;
	}
	
	if (v0 >= 256)
	{
		h0 |= 0x06;
	}
	else if (v1 >= 256)
	{
		h0 |= 0x02;
	}
	*sp = h0;
}
Here it is in full :
Code:
#include <clib/exec_protos.h>
#include <graphics/gfxbase.h>
#include <exec/types.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/blit.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "registers.h"

uint8_t*              screen_ptr =   0;
uint8_t*              smile_sprite_ptr[8];
uint16_t*             copper_list = 0;
uint16_t*             copper_list_end = 0;

const uint16_t SMILE_SPRITE[] = {
	0x2C40,0x3C00, // Vstart.b,Hstart/2.b,Vstop.b,%A0000SEH
	0x07C0,0x0000, // dc.w %     *****      ,%                
	0x1FF0,0x0000, // dc.w %   *********    ,%                
	0x3FF8,0x0000, // dc.w %  ***********   ,%                
	0x7FFC,0x0000, // dc.w % *************  ,%                
	0x67CC,0x1830, // dc.w % **  *****  **  ,%   **     **    
	0xE7CE,0x1830, // dc.w %***  *****  *** ,%   **     **    
	0xFFFE,0x0000, // dc.w %*************** ,%                
	0xFFFE,0x0000, // dc.w %*************** ,%                
	0xFFFE,0x2008, // dc.w %*************** ,%  *         *   
	0xFFFE,0x1830, // dc.w %*************** ,%   **     **    
	0x7FFC,0x07C0, // dc.w % *************  ,%     *****      
	0x7FFC,0x0000, // dc.w % *************  ,%                
	0x3FF8,0x0000, // dc.w %  ***********   ,%                
	0x1FF0,0x0000, // dc.w %   *********    ,%                
	0x07C0,0x0000, // dc.w %     *****      ,%                
	0x0000,0x0000, // dc.w %                ,%                
	0,0
};

const uint16_t spaceship1[] = {
		0x6D60,0x7200,
		0x0C30,0x0000,
		0x1818,0x0420,
		0x342C,0x0E70,
		0x1818,0x0420,
		0x0C30,0x0000,
		0x0000,0x0000,
       
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000
};

const uint16_t spaceship2[] = {
		0x6D60,0x7280,
		0x07E0,0x0000,
		0x0FF0,0x0000,
		0x1FF8,0x0000,
		0x0FF0,0x0000,
		0x07E0,0x0000,
		0x0000,0x0000,
	
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000,
		0x0000,0x0000
};


const uint16_t NULL_SPRITE[] = {
	0x2a20,0x2b00,
	0,0,
	0,0
};


const uint16_t SPR_P[] = {
//SprP:
	0x120, 0x0000, // Sprite 0 SMILE_SPRITE_HIGH (value is defined later)
	0x122, 0x0000, // Sprite 0 SMILE_SPRITE_LOW
        
	0x124, 0x0000, // Sprite 1 NULL_SPRITE_HIGH
	0x126, 0x0000, // Sprite 1 NULL_SPRITE_LOW
        
	0x128, 0x0000, // Sprite 2 NULL_SPRITE_HIGH
	0x12a, 0x0000, // Sprite 2 NULL_SPRITE_LOW
        
	0x12c, 0x0000, // Sprite 3 NULL_SPRITE_HIGH
	0x12e, 0x0000, // Sprite 3 NULL_SPRITE_LOW
        
	0x130, 0x0000, // Sprite 4 NULL_SPRITE_HIGH
	0x132, 0x0000, // Sprite 4 NULL_SPRITE_LOW
        
	0x134, 0x0000, // Sprite 5 NULL_SPRITE_HIGH
	0x136, 0x0000, // Sprite 5 NULL_SPRITE_LOW
        
	0x138, 0x0000, // Sprite 6 NULL_SPRITE_HIGH
	0x13a, 0x0000, // Sprite 6 NULL_SPRITE_LOW
        
	0x13c, 0x0000, // Sprite 7 NULL_SPRITE_HIGH
	0x13e, 0x0000  // Sprite 7 NULL_SPRITE_LOW
};

const uint16_t COPPER_LIST_BEGIN[] = {
//Copper:
	0x1fc,0, // slow fetch mode, AGA compatibility
	COP_MOVE(BPLCON0, 0x0200),
	
	COP_MOVE(DIWSTRT, 0x2c81),
	COP_MOVE(DIWSTOP, 0x2cc1),
	COP_MOVE(DDFSTRT, 0x38),
	COP_MOVE(DDFSTOP, 0xd0),

	COP_MOVE(BPL1MOD, 0x0),
	COP_MOVE(BPL2MOD, 0x0),
	COP_MOVE(BPLCON1, 0x0),
	
	// Background palette
	COP_MOVE(COLOR00, 0x0),
    COP_MOVE(COLOR01, COMBINE_VALUES(0x02, 0x21)),
    COP_MOVE(COLOR02, COMBINE_VALUES(0x02, 0x21)),
    COP_MOVE(COLOR03, COMBINE_VALUES(0x02, 0x22)),
    COP_MOVE(COLOR04, COMBINE_VALUES(0x02, 0x21)),
    COP_MOVE(COLOR05, COMBINE_VALUES(0x03, 0x22)),
    COP_MOVE(COLOR06, COMBINE_VALUES(0x03, 0x21)),
    COP_MOVE(COLOR07, COMBINE_VALUES(0x03, 0x22)),
    COP_MOVE(COLOR08, COMBINE_VALUES(0x02, 0x23)),
    COP_MOVE(COLOR09, COMBINE_VALUES(0x04, 0x33)),
    COP_MOVE(COLOR10, COMBINE_VALUES(0x03, 0x33)),
    COP_MOVE(COLOR11, COMBINE_VALUES(0x04, 0x32)),
    COP_MOVE(COLOR12, COMBINE_VALUES(0x04, 0x32)),
    COP_MOVE(COLOR13, COMBINE_VALUES(0x04, 0x44)),
    COP_MOVE(COLOR14, COMBINE_VALUES(0x03, 0x47)),
    COP_MOVE(COLOR15, COMBINE_VALUES(0x05, 0x43)),
    COP_MOVE(COLOR16, COMBINE_VALUES(0x05, 0x44)),
	
	// Set Sprite palette
	COP_MOVE(COLOR17, 0x0),
	
	COP_MOVE(COLOR18, 0xe22),
	COP_MOVE(COLOR19, 0xff0),
	COP_MOVE(COLOR20, 0xfff),
	
	COP_MOVE(COLOR21, 0xe22),
	COP_MOVE(COLOR22, 0xff0),
	COP_MOVE(COLOR23, 0xfff),
	COP_MOVE(COLOR24, 0xfff),
	
	COP_MOVE(COLOR25, 0xe22),
	COP_MOVE(COLOR26, 0xff0),
	COP_MOVE(COLOR27, 0xfff),
	COP_MOVE(COLOR28, 0x0),
	
	COP_MOVE(COLOR29, 0xe22),
	COP_MOVE(COLOR30, 0xff0),
	COP_MOVE(COLOR31, 0xfff),
};

const uint16_t COPPER_LIST_END[] = {
	//CopBplP:
	COP_MOVE(BPL1PTH, 0x0006), // Screen HIGH WORD 0x0006 default
	COP_MOVE(BPL1PTL, 0x0006), // Screen LOW  WORD 0x0000 default
    COP_MOVE(BPLCON0, 0x1200),  // BPLCON0
   /* COP_MOVE(COLOR00, 0x000),
    
    COP_WAIT_TO_XY(0x07,0x2C),
    COP_MOVE(COLOR00, 0x0f0),
    
    COP_WAIT_TO_XY(0x40, 0x30), // Wait for vpos >= 0x40 and hpos >= 0x30.

    
	COP_WAIT_TO_XY(0x07,0xda),
	COP_MOVE(BPLCON0, 0x1200),  // BPLCON0
    COP_MOVE(COLOR00, 0x0ff),*/
    
	COP_WAIT_END // End Copper
};

void waitRaster(uint32_t value)
{
	uint32_t mask = 0x1FF00;
	uint32_t maskedValue = (value << 8) & mask;
	while ((*VPOS32 & mask) != maskedValue);
}


void createCopperList() {
    size_t size = sizeof(COPPER_LIST_BEGIN) +
                  sizeof(SPR_P) +
                  sizeof(COPPER_LIST_END) +
                  sizeof(SMILE_SPRITE)*8;

    uint16_t* helper = copper_list = (uint16_t*) AllocMem(size, MEMF_CHIP);

    memcpy(helper, COPPER_LIST_BEGIN, sizeof(COPPER_LIST_BEGIN));
    helper += sizeof(COPPER_LIST_BEGIN) / sizeof(uint16_t);

    uint16_t* spr_p_ptr = helper;    
    memcpy(helper, SPR_P, sizeof(SPR_P));
    helper += sizeof(SPR_P) / sizeof(uint16_t);    
    
    copper_list_end = helper;
    memcpy(helper, COPPER_LIST_END, sizeof(COPPER_LIST_END));
    helper += sizeof(COPPER_LIST_END) / sizeof(uint16_t);
    
	for (int i = 0; i < 8; i++)
    {
		smile_sprite_ptr[i] = (uint8_t*) helper;
		memcpy(helper, SMILE_SPRITE, sizeof(SMILE_SPRITE));
		helper += sizeof(SMILE_SPRITE) / sizeof(uint16_t);
	}
	
	uint16_t offset = sizeof(COPPER_LIST_BEGIN) + sizeof(SPR_P) + sizeof(COPPER_LIST_END);
	helper = (uint16_t*)((uint8_t*)copper_list + offset);
	
	smile_sprite_ptr[0] = (uint8_t*) helper;
	memcpy(helper, SMILE_SPRITE, sizeof(SMILE_SPRITE));
	helper += sizeof(SMILE_SPRITE) / sizeof(uint16_t);

	smile_sprite_ptr[1] = (uint8_t*) helper;
	memcpy(helper, SMILE_SPRITE, sizeof(SMILE_SPRITE));
	helper += sizeof(SMILE_SPRITE) / sizeof(uint16_t);

    for (int i = 0; i < 8; i++)
    {
        spr_p_ptr[1 + (i * 4)] = ((uint32_t) smile_sprite_ptr[i]) >> 16;
        spr_p_ptr[3 + (i * 4)] = ((uint32_t) smile_sprite_ptr[i]) & 0xFFFF;
    }
    
}

void destroyCopperList() {
    size_t size = sizeof(COPPER_LIST_BEGIN) +
                  sizeof(SPR_P) +
                  sizeof(COPPER_LIST_END) +
                  sizeof(SMILE_SPRITE)*8;
    
    FreeMem(copper_list, size);
}

void setCopperList(uint16_t* cl) {
    *COP1LCH =((uint32_t) cl) >> 16;
    *COP1LCL =((uint32_t) cl) & 0xFFFF;
}

void waitFrame() {
    do {
        while (*VPOSR_LOW & 1);
    } while (*VPOSHR_HIGH != 0x2a);
}

void waitFrame2() {
    while (*VPOSHR_HIGH != 0x2a );
}

bool leftClick() {
    return (*CIAA_PRA & (1 << 6)) == 0;
}

extern volatile struct Custom* custom;

void Sprite_SetPos(int16_t sx, int16_t sy, int16_t sh, uint8_t* sp, bool attach)
{
	uint16_t h0 = 0x80 + sx;
	uint16_t v0 = 0x2c + sy;
	uint16_t v1 = v0 + sh;
	
	*sp++ = (uint8_t) v0;
	*sp++ = (uint8_t) h0 >> 1;
	
	*sp++ = (uint8_t) v1;
	
	h0 = h0 & 1;
	if (attach)
	{
		h0 |= 0x80;
	}
	
	if (v0 >= 256)
	{
		h0 |= 0x06;
	}
	else if (v1 >= 256)
	{
		h0 |= 0x02;
	}
	*sp = h0;
}

int main(int argc, char** argv)
{   
	int i;
uint8_t y = 0;
	uint16_t x = 0;

	uint16_t old_INTENA = *INTENAR;
	uint16_t old_DMACON = *DMACONR;
        
	waitRaster(0x0138);
        
	*INTENAW = 0x7FFF; // Disable all bits in INTENA
	*INTREQW = 0x7FFF; // Idem
	*DMACONW = 0x7FFF; // Disable all bits in DMACON
	*DMACONW = 0x87E0; // Setting DMA channels

	createCopperList();
	setCopperList(copper_list);

	for(i=2;i<8;i++)
	{
		Sprite_SetPos(0 + i*16, 50, 16, smile_sprite_ptr[i], 0);
		//Sprite_SetPos(i, 0, 0 + (i * 16));
	}
	
	while (true)
	{
		waitFrame();
		waitFrame2();
		Sprite_SetPos(0, y, 16, smile_sprite_ptr[0], 1);
		Sprite_SetPos(0, y, 16, smile_sprite_ptr[1], 1);
	}
	destroyCopperList();

    return 0;
}
And registers.h if you need it :
Code:
#ifndef REGISTERS_H
#define REGISTERS_H

volatile uint16_t* const DMACONR     = (uint16_t* const) 0xDFF002;
volatile uint32_t* const VPOS32      = (uint32_t* const) 0xDFF004;
volatile uint16_t* const VPOSR       = (uint16_t* const) 0xDFF004;
volatile uint8_t*  const VPOSR_LOW   = (uint8_t*  const) 0xDFF005;
volatile uint16_t* const VPOSHR      = (uint16_t* const) 0xDFF006;
volatile uint8_t*  const VPOSHR_HIGH = (uint8_t*  const) 0xDFF006;
volatile uint8_t*  const VPOSHR_LOW  = (uint8_t*  const) 0xDFF007;
volatile uint16_t* const INTENAR     = (uint16_t* const) 0xDFF01C;
volatile uint32_t* const COP1LC32    = (uint32_t* const) 0xDFF080;
volatile uint16_t* const COP1LCH     = (uint16_t* const) 0xDFF080;
volatile uint16_t* const COP1LCL     = (uint16_t* const) 0xDFF082;
volatile uint16_t* const COP2LCH     = (uint16_t* const) 0xDFF084;
volatile uint16_t* const COP2LCL     = (uint16_t* const) 0xDFF086;
volatile uint16_t* const DMACONW     = (uint16_t* const) 0xDFF096;
volatile uint16_t* const INTENAW     = (uint16_t* const) 0xDFF09A;
volatile uint16_t* const INTREQW     = (uint16_t* const) 0xDFF09C;
volatile uint8_t*  const CIAA_PRA    = (uint8_t* const ) 0xBFE001;

// 20 instead of 127 because of input.device priority
#define TASK_PRIORITY           (20)
#define PRA_FIR0_BIT            (1 << 6)
#define BPLCON0_COMPOSITE_COLOR (1 << 9)

// copper instruction macros
#define COP_MOVE(addr, data) addr, data
#define COP_WAIT_END  0xffff, 0xfffe
#define COMBINE_VALUES(a, b) ((b << 8) | a)
#define COP_WAIT_TO_XY(x,y) COMBINE_VALUES(x,y),0xfffe
#define COP_WAIT_TO(a) a,0xfffe
#define COP_NOP 0x01fe, 0x0000

// Registers
#define COLOR00    0x180
#define COLOR01    0x182
#define COLOR02    0x184
#define COLOR03    0x186
#define COLOR04    0x188
#define COLOR05    0x18a
#define COLOR06    0x18c
#define COLOR07    0x18e
#define COLOR08    0x190
#define COLOR09    0x192
#define COLOR10    0x194
#define COLOR11    0x196
#define COLOR12    0x198
#define COLOR13    0x19a
#define COLOR14    0x19c
#define COLOR15    0x19e
#define COLOR16    0x1a0
#define COLOR17    0x1a2
#define COLOR18    0x1a4
#define COLOR19    0x1a6
#define COLOR20    0x1a8
#define COLOR21    0x1aa
#define COLOR22    0x1ac
#define COLOR23    0x1ae
#define COLOR24    0x1b0
#define COLOR25    0x1b2
#define COLOR26    0x1b4
#define COLOR27    0x1b6
#define COLOR28    0x1b8
#define COLOR29    0x1ba
#define COLOR30    0x1bc
#define COLOR31    0x1be
#define BPLCON0    0x100
#define BPLCON1    0x102
#define BPL1PTH    0xe0
#define BPL1PTL    0xe2
#define BPL2PTH    0xe4
#define BPL2PTL    0xe6
#define BPL3PTH    0xe8
#define BPL3PTL    0xea
#define BPL4PTH    0xec
#define BPL4PTL    0xee
#define BPL5PTH    0xf0
#define BPL5PTL    0xf2
#define BPL1MOD    0x108
#define BPL2MOD    0x10a
#define DIWSTRT    0x8e
#define DIWSTOP    0x90
#define DDFSTRT    0x92
#define DDFSTOP    0x94
#define DMA       0x96

#define SPR0PTH 0x14
#define SPR0PTL 0x16
#define SPR0POS 0x1e
#define SPR0CTL 0x28
#define SPR0DATA 0x2e

#define SPR1PTH 0x34
#define SPR1PTL 0x36
#define SPR1POS 0x3e
#define SPR1CTL 0x48
#define SPR1DATA 0x4e

#define SPR2PTH 0x54
#define SPR2PTL 0x56
#define SPR2POS 0x5e
#define SPR2CTL 0x68
#define SPR2DATA 0x6e

#define SPR3PTH 0x74
#define SPR3PTL 0x76
#define SPR3POS 0x7e
#define SPR3CTL 0x88
#define SPR3DATA 0x8e

#define SPR4PTH 0x94
#define SPR4PTL 0x96
#define SPR4POS 0x9e
#define SPR4CTL 0xa8
#define SPR4DATA 0xae

#define SPR5PTH 0xb4
#define SPR5PTL 0xb6
#define SPR5POS 0xbe
#define SPR5CTL 0xc8
#define SPR5DATA 0xce

#define SPR6PTH 0xd4
#define SPR6PTL 0xd6
#define SPR6POS 0xde
#define SPR6CTL 0xe8
#define SPR6DATA 0xee

#define SPR7PTH 0xf4
#define SPR7PTL 0xf6
#define SPR7POS 0xfe
#define SPR7CTL 0x108
#define SPR7DATA 0x10e

#endif

Now i need to look more into Copper/Blitter stuff... (I'm using the OS calls for those so far but obviously it's not ideal)
gameblabla is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga 1200 problems, displaying only scanlines over a black image Liam Hallows support.Hardware 3 28 November 2020 09:47
AES-256 ECB file encryption tool for classic Amiga modrobert Coders. Releases 44 24 March 2015 14:23
universe amiga 500 256 colors ! ? turrican3 Retrogaming General Discussion 14 09 April 2014 21:35
Is it possible to somehow make Amiga version of some games 256 colours? ancalimon project.Amiga Game Factory 7 06 December 2009 03:27
Pal Amiga is 256 redblade Retrogaming General Discussion 9 05 April 2006 16:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:19.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07348 seconds with 15 queries