diff --git a/021.calling_c/c_code.c b/021.calling_c/c_code.c index bbbae09..79657c0 100644 --- a/021.calling_c/c_code.c +++ b/021.calling_c/c_code.c @@ -14,7 +14,8 @@ PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned static unsigned short _copperData; static unsigned char _bitplaneData; -static void + +void TestCall() { PokeBitplanePointers(&_copperData, &_bitplaneData, 3, 4, 5); diff --git a/021.calling_c/calling_c.s b/021.calling_c/calling_c.s index 772ecec..d9a50c2 100644 --- a/021.calling_c/calling_c.s +++ b/021.calling_c/calling_c.s @@ -28,7 +28,9 @@ Entry: ;=========================================================== if 0 -PokeBitplanePointers: ; d0 = frame offset in bytes, a0 = BPLP copper list address +PokeBitplanePointers: + ; d0 = frame offset in bytes; + ; a0 = BPLP copper list address movem.l d0-a6,-(sp) move.l bitplanes,a1 add.l d0,a1 ; Offset for odd/even frames diff --git a/021.calling_c/init.s b/021.calling_c/init.s index b54d055..d697881 100644 --- a/021.calling_c/init.s +++ b/021.calling_c/init.s @@ -19,14 +19,15 @@ Init: jsr PokeBitplanePointers endif - ;; void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes) - move.l #SCREEN_WIDTH_BYTES,-(sp) - move.l #SCREEN_BIT_DEPTH,-(sp) - move.l #0,-(sp) - pea bitplanes - pea copperList - jsr _PokeBitplanePointers - add.l #20,sp + ;; 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 + 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 ;; set up playfield move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6) diff --git a/shared/base.mk b/shared/base.mk index 3a4398d..972a1d3 100644 --- a/shared/base.mk +++ b/shared/base.mk @@ -93,6 +93,7 @@ out/%.o: %.s out/%.o: %.c vc -O3 -c $< -o $@ -@vc -O3 -S $< -o out/$*.s > /dev/null 2> /dev/null + -@vc -O0 -S $< -o out/$*-noopt.s > /dev/null 2> /dev/null out/main.bin: out/main.o $(OBJS) @#-T ../link.script