11 December 2009, 00:24 | #1 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
AGA C2P....help!
I'm currently trying to stick someone's assembler C2P routine into my C++ project, I think I've now got the bugger to link properly but it's not actually working yet.
As I'm crap at assembler can someone have a look at the attached routines and tell me (a) what I should be passing as arguments and (b) if any better routines exist. http://home.iprimus.com.au/novacoder/c2p_030.h http://home.iprimus.com.au/novacoder/c2p_030.s http://home.iprimus.com.au/novacoder/c2p_030.o The init method seems to work ok (as in it doesn't crash). Code:
extern "C" void c2p1x1_cpu3blit1_queue_init ( UWORD chunkyx, // width UWORD chunkyy, // height UWORD scroffsy, // y offset ULONG bplsize, // modulo to next plane ULONG signals1, ULONG signals3, struct Task *thistask, struct Task *other Code:
extern "C" void c2p1x1_cpu3blit1_queue ( UBYTE *c2pscreen, UBYTE *bitplanes); Thanks Last edited by NovaCoder; 11 December 2009 at 00:31. |
11 December 2009, 00:38 | #2 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
In particular I'm having trouble with the c2pscreen argument, not sure what that should be.
|
11 December 2009, 00:49 | #3 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
Pointer to the chunky buffer?
|
11 December 2009, 01:08 | #4 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
Well that's what I assumed but it just hangs.
I'm doing this for a 320x200 bit bit chunky display: Code:
static byte *backBuffer; backBuffer=(byte*)malloc(64000); Code:
void I_FinishUpdate () { int top, left, width, height; total_frames++; left = 0; top = 0; width = SCREENWIDTH; height = SCREENHEIGHT; if (video_is_native_mode) { if (video_is_using_blitter) { start_timer(); Wait (1 << video_sigbit1); /* wait for prev c2p() to finish pass 3 */ blit_time += end_timer(); if (video_blit_is_in_progress) { start_timer(); Wait (SIGBREAKF_CTRL_F); /* wait for prev ChangeScreenBuffer() safe */ safe_time += end_timer(); video_blit_is_in_progress = FALSE; } video_which = 1 - video_which; /* render to the hidden bitmap */ start_timer(); c2p1x1_cpu3blit1_queue (backBuffer, video_raster[video_which]); c2p_time += end_timer(); video_blit_is_in_progress = TRUE; } } } |
11 December 2009, 13:09 | #5 |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
The C code sends the arguments on the stack, but the assembly code expects them in registers.
Either A) change the C function prototype to specify register locations for all arguments (exact syntax is compiler dependent) or B) change the assembly code to load register contents from the stack. |
11 December 2009, 22:54 | #6 | |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
Quote:
Code:
#ifndef __GNUC__ #define REG(reg,arg) register __##reg arg #else #define REG(reg,arg) arg __asm(#reg) #endif extern void c2p1x1_cpu3blit1_queue_init ( REG(d0, UWORD chunkyx), // width REG(d1, UWORD chunkyy), // height REG(d3, UWORD scroffsy), // y offset REG(d5, ULONG bplsize), // modulo to next plane REG(d6, ULONG signals1), REG(d7, ULONG signals3), REG(a2, struct Task *thistask), REG(a3, struct Task *othertask), REG(a4, UBYTE *chipbuff)); extern void c2p1x1_cpu3blit1_queue ( REG(a0, UBYTE *c2pscreen), REG(a1, UBYTE *bitplanes)); Last edited by NovaCoder; 12 December 2009 at 00:18. |
|
12 December 2009, 00:18 | #7 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
Salass00 also come up with this idea:
If you can't use register arguments (IIRC C++ doesn't support this) then you can create small assembler stub functions that take arguments on the stack and put them in the correct registers like this: Code:
XREF _c2p1x1_cpu3blit1_queue_init XREF _c2p1x1_cpu3blit1_queue XDEF _c2p1x1_cpu3blit1_queue_init_stub XDEF _c2p1x1_cpu3blit1_queue_stub _c2p1x1_cpu3blit1_queue_init_stub: movem.l 4(a7),d0-d1/d3/d5-d7/a2-a4 jsr _c2p1x1_cpu3blit1_queue_init rts _c2p1x1_cpu3blit1_queue_stub movem.l 4(a7),a0-a1 jsr _c2p1x1_cpu3blit1_queue rts Then in your C++ code you use these two functions instead: Code:
extern "C" void c2p1x1_cpu3blit1_queue_init_stub (UWORD chunkyx, UWORD chunkyy, UWORD scroffsy, ULONG bplsize, ULONG signals1, ULONG signals3, struct Task *thistask, struct Task *othertask, UBYTE *chipbuff); extern "C" void c2p1x1_cpu3blit1_queue_stub (UBYTE *c2pscreen, UBYTE *bitplanes); |
12 December 2009, 03:19 | #8 | |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
Quote:
The stub below preserves registers properly: Code:
_c2p1x1_cpu3blit1_queue_init_stub: movem.l d2-d7/a2-a6,-(sp) movem.l 11*4+4(a7),d0-d1/d3/d5-d7/a2-a4 jsr _c2p1x1_cpu3blit1_queue_init movem.l (sp)+,d2-d7/a2-a6 rts |
|
17 December 2009, 00:15 | #9 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,408
|
For other's reference, this got it working (thanx Salass00)
Code:
XREF _c2p1x1_cpu3blit1_queue_init XREF _c2p1x1_cpu3blit1_queue XDEF _c2p1x1_cpu3blit1_queue_init_stub XDEF _c2p1x1_cpu3blit1_queue_stub _c2p1x1_cpu3blit1_queue_init_stub: movem.l d3/d5-d7/a2-a4,-(a7) movem.l 32(a7),d0-d1/d3/d5-d7/a2-a4 jsr _c2p1x1_cpu3blit1_queue_init movem.l (a7)+,d3/d5-d7/a2-a4 rts _c2p1x1_cpu3blit1_queue_stub: movem.l 4(a7),a0-a1 jsr _c2p1x1_cpu3blit1_queue rts |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Any C2P experts here? | oRBIT | Coders. General | 36 | 27 April 2010 07:26 |
HAM8 C2P Hacking | NovaCoder | Coders. General | 2 | 25 March 2010 10:37 |
C2P Speed question | Thorham | Coders. General | 5 | 20 January 2010 04:27 |
Gloom Akiko C2P? | Whitesnake | support.Games | 5 | 23 April 2007 19:01 |
Game in c2p? | oRBIT | Amiga scene | 11 | 01 February 2007 21:28 |
|
|