; $$$$$$$$$$$$$$$$$$$ ABAKIS $$$$$$$$$$$$$$$$$$$$$ ; *************** STAR^2 SOFTWARE **************** ; ;;;;;;;;;;;;;;;;;;; IMAGE ;;;;;;;;;;;;;;;;;;;;;; ; image class/object/structure macro IMAGE a { a: void a#.p integer a#.x, a#.y, a#.w, a#.h integer a#.bpp=32, a#.key, a#.alpha } virtual at 0 ?image.p dd 0 ?image.x dd 0 ?image.y dd 0 ?image.w dd 0 ?image.h dd 0 ?image.bpp dd 32 ?image.key dd 0 ?image.alpha dd 0 END virtual ?image.box fix ?image.x ; create image file/s with header: ; 8 bytes: ; byte s='I' ; signature ; byte v=0 ; version: AABBCC.VV ; int16 w, h ; size: w:h ; byte bpp ; bpp: 32/24/16/15/8 ; byte n ; # colors or 0=256+ ; byte pixels[w*h*(bpp/8)] ; or *2 if 15 macro IMAGE [p] { forward local w, h w=0 h=0 define ?s 0 match a==b, p \{ \local ..q ..q: inject.image b, 32 load w word from ..q+2 load h word from ..q+4 a: void a\#.p=..q+8 integer a\#.x, a\#.y, a\#.w=w, a\#.h=h integer a\#.bpp, a\#.key, a\#.alpha define ?s 1 \} IF ?s eq 0 IMAGE p END IF } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; load 24PP .BMP, store as .IMAGE 15/16/24/32. ; for OSs, ROMs. warning: causes slow compile ; with 1+ MB worth of images. to compile fast ; without images, comment "; IMAGE name='abc'" macro inject.image name, bpp { local i, p, a, r, g, b,\ x, y, w, h, wb virtual at 0 p:: file CD#'media/'#name#'.bmp' END virtual IF ~bpp in <15,16,24,32> 'Invalid BPP' name END IF load a word from p:0 IF a<>'BM' 'Invalid signature' name END IF load a byte from p:1Ch IF a<>24 'Must be 24BPP' name END IF load w dword from p:12h load h dword from p:16h db 'I', 0 dw w, h db bpp, 0 a=((3-((w*3)+3)) and 3) wb=(w*3)+a y=h WHILE y>0 o=36h+((y-1)*wb) x=0 WHILE x'BM' 'Invalid signature' name END IF load a byte from p:1Ch IF a<>8 'Must be 8BPP' name END IF load w dword from p:12h load h dword from p:16h db 'I', 0 dw w, h db 8, 0 i=0 WHILE i<256 o=36h+(i*4) load b byte from p:o load g byte from p:o+1 load r byte from p:o+2 db b, g, r, 0 i=i+1 END WHILE a=((3-(w+3)) and 3) wb=w+a y=h WHILE y>0 o=436h+((y-1)*wb) x=0 WHILE x