mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-13 07:43:29 +00:00
Updated calling C example
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
SHRINKLER=0
|
||||
INTERLACE=0
|
||||
INTERLACE=1
|
||||
HAM_MODE=1
|
||||
|
||||
EXAMPLE_NAME=calling_c
|
||||
|
||||
+17
-16
@@ -6,27 +6,28 @@ typedef union {
|
||||
} words;
|
||||
} word_extract_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned short pad1;
|
||||
unsigned short lo;
|
||||
unsigned short pad2;
|
||||
unsigned short hi;
|
||||
} copper_layout_t
|
||||
|
||||
|
||||
void
|
||||
PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes)
|
||||
PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned short interlace, unsigned short numBitplanes, unsigned short screenWidthBytes)
|
||||
{
|
||||
int i;
|
||||
copper += offset;
|
||||
char i;
|
||||
word_extract_t extract;
|
||||
copper_layout_t *ptr = copper;
|
||||
|
||||
bitplanes += interlace ? screenWidthBytes*numBitplanes : 0;
|
||||
|
||||
for (i = 0; i < numBitplanes; i++) {
|
||||
word_extract_t extract;
|
||||
extract.ptr = bitplanes;
|
||||
*(copper+1) = extract.words.lo;
|
||||
*(copper+3) = extract.words.hi;
|
||||
ptr->lo = extract.words.lo;
|
||||
ptr->hi = extract.words.hi;
|
||||
bitplanes += screenWidthBytes;
|
||||
copper += 4;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned short _copperData;
|
||||
static unsigned char _bitplaneData;
|
||||
|
||||
void
|
||||
TestCall()
|
||||
{
|
||||
PokeBitplanePointers(&_copperData, &_bitplaneData, 3, 4, 5);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include "includes.i"
|
||||
|
||||
xref InstallColorPalette
|
||||
;;xref PokeBitplanePointers
|
||||
xref PokeBitplanePointers
|
||||
xref copperList
|
||||
xref copperListAlternate
|
||||
xref bitplanes
|
||||
@@ -27,12 +27,12 @@ Entry:
|
||||
bra .mainLoop
|
||||
|
||||
;===========================================================
|
||||
if 0
|
||||
if 1
|
||||
PokeBitplanePointers:
|
||||
; d0 = frame offset in bytes;
|
||||
; a0 = BPLP copper list address
|
||||
movem.l d0-a6,-(sp)
|
||||
move.l bitplanes,a1
|
||||
lea bitplanes,a1
|
||||
add.l d0,a1 ; Offset for odd/even frames
|
||||
moveq #SCREEN_BIT_DEPTH-1,d0
|
||||
.bitplaneloop:
|
||||
|
||||
+15
-10
@@ -12,22 +12,27 @@ Init:
|
||||
;; set up default palette
|
||||
jsr InstallColorPalette
|
||||
|
||||
;; Make a call to a C function with the following prototype:
|
||||
;; void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned short interlace, unsigned short numBitplanes, unsigned short screenWidthBytes)
|
||||
|
||||
if INTERLACE == 1
|
||||
;; poke the bitplane pointers for the two copper lists.
|
||||
move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d0
|
||||
lea copperListAlternate,a0
|
||||
jsr PokeBitplanePointers
|
||||
move.l #SCREEN_WIDTH_BYTES,-(sp) ; arguments are pushed onto the stack...
|
||||
move.l #SCREEN_BIT_DEPTH,-(sp) ; in reverse order. 16 bit variables are passed as 32 bits.
|
||||
move.l #1,-(sp) ; interlace line.
|
||||
pea bitplanes ; make sure you push the address...
|
||||
pea copperListAlternate ; of variables, not the value.
|
||||
jsr _PokeBitplanePointers ; C adds an _ to all global symbols.
|
||||
add.l #20,sp ; Need to pop the arguments from the stack.
|
||||
endif
|
||||
|
||||
;; Make a call to a C function with the following prototype:
|
||||
;; void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes)
|
||||
move.l #SCREEN_WIDTH_BYTES,-(sp) ; arguments are pushed onto the stack...
|
||||
move.l #SCREEN_BIT_DEPTH,-(sp) ; in reverse order
|
||||
move.l #0,-(sp) ; offset == 0
|
||||
move.l #SCREEN_BIT_DEPTH,-(sp) ; in reverse order.
|
||||
move.l #0,-(sp) ; normal line.
|
||||
pea bitplanes ; make sure you push the address...
|
||||
pea copperList ; of variables, not the value
|
||||
jsr _PokeBitplanePointers ; C adds an _ to all global symbols
|
||||
add.l #20,sp ; Need to pop the arguments from the stack
|
||||
pea copperList ; of variables, not the value.
|
||||
jsr _PokeBitplanePointers ; C adds an _ to all global symbols.
|
||||
add.l #20,sp ; Need to pop the arguments from the stack.
|
||||
|
||||
;; set up playfield
|
||||
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
|
||||
|
||||
Reference in New Issue
Block a user