1; void __CALLEE__ sp1_InitCharStruct_callee(struct sp1_cs *cs, void *drawf, uchar type, void *graphic, uchar plane)
2; 05.2007 aralbrec, Sprite Pack v3.0
3; sinclair spectrum version
4
5PUBLIC sp1_InitCharStruct_callee
6PUBLIC ASMDISP_SP1_INITCHARSTRUCT_CALLEE
7
8EXTERN _sp1_struct_cs_prototype
9EXTERN SP1V_ROTTBL
10
11.sp1_InitCharStruct_callee
12
13   pop hl
14   pop bc
15   ld a,c
16   ex af,af
17   pop bc
18   pop de
19   ld a,e
20   pop de
21   ex (sp),hl
22
23; enter : a' = plane
24;          a = type
25;         hl = struct sp1_cs *
26;         de = address of sprite draw function
27;         bc = graphic
28; uses  : af, bc, de, hl, af', bc', de', hl'
29
30.asmentry
31
32   push bc                     ; save graphic
33   push de                     ; save draw function
34
35   ex de,hl                    ; de = struct sp1_cs *
36   ld hl,_sp1_struct_cs_prototype
37   ld bc,24
38   ldir                        ; copy prototype struct sp1_cs into sp1_cs
39
40   ld hl,-5
41   add hl,de                   ; hl = & sp1_cs.draw + 1b
42   pop de
43   dec de                      ; de = & last byte of draw function data
44   ex de,hl
45
46   ldd                         ; copy draw function data into struct sp1_cs
47   ldd
48   ldd
49   dec hl
50   dec hl
51   dec de
52   dec de
53   ldd
54   ldd
55   pop bc                      ; bc = graphic
56   ex de,hl
57   ld (hl),b
58   dec hl
59   ld (hl),c
60   dec hl
61   dec de
62   dec de
63   ex de,hl
64   ldd
65
66   ex de,hl                    ; hl = & sp1_cs.ss_draw + 1b
67   ld (hl),sp1_ss_embedded / 256
68   dec hl
69   ld (hl),sp1_ss_embedded % 256
70
71   dec hl
72   dec hl
73   dec hl                      ; hl = & sp1_cs.type
74   ld (hl),a                   ; store type
75   dec hl
76   ex af,af
77   ld (hl),a                   ; store plane
78
79   ret
80
81.sp1_ss_embedded
82
83   ld a,SP1V_ROTTBL/256 + 8    ; use rotation of four pixels if user selects a non-NR draw function
84   ld bc,0
85   ex de,hl
86   jp (hl)
87
88DEFC ASMDISP_SP1_INITCHARSTRUCT_CALLEE = asmentry - sp1_InitCharStruct_callee
89