@@ -133,27 +133,27 @@ _AllocSprite:
133
133
; arg2 : pointer to malloc routine
134
134
; Returns:
135
135
; Pointer to allocated sprite, first byte width, second height
136
- ld iy , 0
137
- add iy , sp
138
- ld l , (iy + 3 ) ; l = width of sprite
139
- ld h , (iy + 6 ) ; h = height of sprite
140
- ld iy , (iy + 9 ) ; iy = pointer to some malloc
141
- push hl
142
- mlt hl ; width * height
143
- inc hl
144
- inc hl ; allocate space for width and height bytes
145
- push hl
146
- call __indcall ; call the malloc routine
147
- pop de
148
- pop de
149
- add hl , de
150
- or a , a
151
- sbc hl , de
152
- ret z ; check to make sure malloc did not fail
153
- ld (hl) , e ; store width
154
- inc hl
155
- ld (hl) , d ; store height
156
- dec hl ; return sprite pointer
136
+ ld bc , 3
137
+ push bc
138
+ pop hl
139
+ add hl , sp
140
+ ld e , (hl ) ; e = width
141
+ add hl , bc
142
+ ld d , (hl) ; d = height
143
+ add hl , bc
144
+ ld hl , (hl) ; hl = malloc
145
+ push de
146
+ mlt de ; de = width * height
147
+ inc de ; +2 to store width and height
148
+ inc de ; de = width * height + 2
149
+ push de
150
+ call _indcallHL_ASM \.r ; hl = malloc(width * height + 2)
151
+ pop de ; de = width * height + 2
152
+ add hl , de ; this should never carry
153
+ sbc hl , de ; check if malloc failed (hl == 0)
154
+ pop de ; e = width, d = height
155
+ ret z ; abort if malloc failed
156
+ ld (hl) , de ; store width and height
157
157
ret
158
158
159
159
;-------------------------------------------------------------------------------
@@ -2689,6 +2689,11 @@ _SetTextXY:
2689
2689
ld (TextYPos_SMC) , hl \.r
2690
2690
push hl ; xpos=don't care, sp=&xpos
2691
2691
ex de , hl ; hl=return address
2692
+ ;-------------------------------------------------------------------------------
2693
+ _indcallHL_ASM:
2694
+ ; Calls HL
2695
+ ; Inputs:
2696
+ ; HL : Address to call
2692
2697
jp (hl)
2693
2698
2694
2699
;-------------------------------------------------------------------------------
0 commit comments