jimomura@lsuc.on.ca (Jim Omura) (11/03/90)
This has been a fairly mixed day for me. I've been writing
Line-A bindings for Sozobon C and testing them. For the most
part it's been fairly successful. During the morning, I wrote
a few that worked and I was feeling very happy waltzing back
to my computer after lunch. But the afternoon was not so
nice. I made a few changes that worked, but one has got
me stumped. It's not an entirely necessary function, since
I have an alternative which works, but is not crude.
The A-Line routines generally make use of a lot of
data located in an area that can be thought of as a structure.
But most of the functions use a lot of data and it's not
necessary to set them all for each function call. So I broke
them down into smaller specialized functions. Nothing new about
this. One of my function calls is FOREGRND(). The foreground
colour for most of the A-Line functions is set by 4 contiguous
'short' values starting at the 24th byte offset from the the
start of the variable structure
24 bit plane 1
26 bit plane 2
28 bit plane 3
30 bit plane 4
That looks easy enough. My first approach was as follows:
.text
.globl _foregrnd
_foregrnd:
; foregrnd(spntr,plane1,plane2,plane3,plane4)
; Line-A binding for Sozobon C
; By Jim Omura
bra L1
L0:
;var 4 8 _spntr
;var 2 12 _plane1
;var 2 14 _plane2
;var 2 16 _plane3
;var 2 18 _plane4
;
movea.l 8(a6),a3 ; A3 = spntr
move.w 12(a6),24(a3)
move.w 14(a6),26(a3)
move.w 16(a6),28(a3)
move.w 18(a6),30(a3)
;
L2:
unlk a6
rts
L1:
link a6,#-0
bra L0
.data
When I ran it with a test program, it worked. No
surprises. But crude? Yeah. Why pass 4 ints for 1 colour
register value? Better to just pass the colour register as
a single int and then unpack it in the function call right?
So I wrote the following:
.text
.globl _foregrnd
_foregrnd:
; foregrnd(spntr,colour)
; LINE_A spntr
; int colour
; Line-A binding function for Sozobon C
; By Jim Omura
bra L1
L0:
;var 4 8 _spntr
;var 2 12 _colour
;
movea.l 8(a6),a3 ; A3 = spntr
adda.l #24,a3 ; A3 points at Plane 1
move.w #3,d3 ; D3 = Loop Counter
move.w 12(a6),d4 ; D4 = Colour Reg.
;
DIST: ; Start Loop
lsr.b #1,d4 ; Shift bytewide right
; NOTE: Last Bit shifted out sets CCR Carry and eXtend Flags
bcs ODD ; Branch Carry Set
move.w #0,(a3)+ ; Bit Plane = 0 & Incr. A3
bra NEXT
ODD: move.w #1,(a3)+ ; Bit Plane = 1 & Incr. A3
NEXT:
dbra d3,DIST ; End of Loop
;
L2:
unlk a6
rts
L1:
link a6,#-0
bra L0
.data
Well, as far as *I* can see, this should have worked.
It assembles fine. But when I ran it in my test program I
ended up with 3 Cherry bombs. Not fun. I've spent hours
trying to figure out what's going wrong, but I can't see
anything wrong with it. Well, if I did, I'd have corrected
right? :-) Can anybody see what I'm doing wrong here?
Cheers! -- Jim O.
--
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
lsuc!jimomura
Byte Information eXchange: jimomura