← EGFX function index

EGFX · FUNCTION 36ALPHA · USE AT YOUR OWN RISK

COMPACT_INIT

Prepare sideways RAM for a compact pack.

Checks that the given sideways bank is writable (with a reversible probe), switches it to compact-resource mode and resets the upload pointer. Follow it with RESOURCE_UPLOAD (17) blocks of up to 48 bytes covering the whole file, header included, then RESOURCE_READY (18). The pack is then drawable with COMPACT_SPRITE (37) at page &80 of that bank. Read-only banks are rejected.

Known issue: PROCegloadcompact in the current gfx-basic.bas still expects the old EGSP v2 header, so it rejects v3 packs with BAD SPRITES. Until it is fixed, use the short loader in this example.

Parameters

NameBytesDescription
BANK8writable sideways RAM slot
LENGTH9–10complete file length, 8–8200 bytes

BASIC example

Tested listing: ex36.bas, run in B-em on a Master 128. Append the EGFX helpers from gfx-basic.bas (the build does this for you), and put the Breakout EGASSETS.rom (with the beta release) in slot 7 where the example draws from &81/&87.

10 MODE 1:HIMEM=&2400:PROCeginit
20 PROCloadv3("SPRITES",6)
30 PROCegbegin
40 FOR i%=2 TO 7:PROCegcompact(40+i%*24,100,i%,0,6,&80):NEXT
50 PROCegtext("FN36 OK",8,8):PROCegpresent
60 END
100 DEF PROCloadv3(f$,b%):LOCAL h%,n%,o%,c%,i%
110 h%=OPENIN(f$):IF h%=0 PRINT "NO FILE":END
120 n%=EXT#h%:egb%?8=b%:egb%?9=n% AND 255:egb%?10=n% DIV 256:PROCegcall(36):o%=0
130 REPEAT:c%=n%-o%:IF c%>48 c%=48
140 FOR i%=0 TO c%-1:egb%?(16+i%)=BGET#h%:NEXT
150 egb%?8=o% AND 255:egb%?9=o% DIV 256:egb%?10=c%:PROCegcall(17):o%=o%+c%
160 UNTIL o%=n%:CLOSE#h%:PROCegcall(18):ENDPROC

Assembly

        LDA #36 : STA block+5      ; function
        LDA #0  : STA block+7      ; clear ACK
        LDA #&C0 : LDX #block MOD 256 : LDY #block DIV 256
        JSR &FFF1                  ; OSWORD &C0; block+7 = &A5 on success

← Function index