rem BMPColourSwap (Assembly Version) ... Rev 6.2 rem A J Tooth // 23rd November 2003 Modified May 2006 rem==================================================================== rem This program generates 12 variants of a standard .bmp file rem by swapping and complementing the r/g/b values. rem==================================================================== rem =================================================================== on error if (err=17) then quit himem=lomem + 100000000 *FLOAT 64 install @lib$+"MyUtils.bbc" install @lib$+"BMP_Utils.bbc" rem =================================================================== rem Goto fullscreen proc_fullscreen(xscreen%,yscreen%) rem Pick a .bmp picture proc_pichoose(pic$, fil$, pre$, wdth%, hght%, lgth%, pf%) rem Display the .bmp as is proc_BMP_DispB(xscreen%,yscreen%,pf%) print tab(5,5);"Left-click or press any key to continue." proc_event(a$,b&) cls rem 2nd pass setup proc_setup2 rem Colour swap versions. proc_swap print tab(0,1);"DONE" proc_event(a$,b&) quit end rem End of Program +++++++++++++++++++++++++++++++++++++++++++++++ rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rem Read in the .bmp to a file in memory def proc_setup2 proc_BMP_Set(wdth%,hght%,pfmir%,Wlim%,ntused%) dim bsave% 100, g% 0 rem Dual-pass assembly, in case of labels for pass&=0 to 2 step 2 proc_bsave(pass&) next pass& dim swop% 1000, bl% 0, gr% 0, re% 0, bn% 0, gn% 0, rn% 0 rem Dual-pass assembly, in case of labels for pass&=0 to 2 step 2 proc_swop(pass&) next pass& endproc rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rem Colour swap versions. def proc_swap print tab(15,15);"PLEASE WAIT ABOUT 3 SECONDS." print tab(5,17);"Once the pictures start appearing, you will see a little red number" print tab(5,18);"at the top left of the screen. Once the last (12th) appears, it will say DONE." print tab(5,20);"Each picture is saved as 'Testa/b/c.bmp' etcetera in the same directory as the original." print tab(5,21);"Thereafter you can modify it further using a Picture Editor, if you wish." for r&=1 to 12 sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &100 rem Swap colours call swop% sys "GetCurrentProcess" to hprocess% sys "SetPriorityClass", hprocess%, &20 rem Save pictures to disc Dpath$=pre$+"Test"+chr$(96+(r&))+".bmp" ?g%=openout Dpath$ call bsave% : rem Byte Save Routine close#(?g%) rem Display Picture proc_BMP_DispB(xscreen%,yscreen%,pfmir%) rem Display which version in top left corner. Not saved in .bmp colour 1 : print tab(0,0);r& next r& endproc rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rem Byte Save - Assembly Routine def proc_bsave(opt&) P%=bsave% [opt opt& mov ebx,0 mov bl,[g%] ;Puts channel ref t0 ebx mov edx,0 mov [^w%],edx ;Initialise loop counter .loop mov al,pfmir%[edx] call "osbput" ;Puts al t0 channel ebx inc dword [^w%] mov edx,[^w%] cmp edx,[^lgth%] jl loop ret ] endproc rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rem Colour Swap - Assembly Routine def proc_swop(opt&) P%=swop% [opt opt& mov edx,0 mov [^j%],edx .jloop mov edx,0 mov [^k%],edx .kloop mov eax,[^Wlim%] imul eax,[^j%] add eax,[^k%] add eax,[^k%] add eax,[^k%] add eax,54 mov ebx,eax mov al,[^r&] cmp al,6 jle under7 mov dl,pf%[ebx] ;Set blue/green/red INVERSE When r%>6 mov cl,255 sub cl,dl mov [bl%],cl mov dl,pf%[ebx+1] mov cl,255 sub cl,dl mov [gr%],cl mov dl,pf%[ebx+2] mov cl,255 sub cl,dl mov [re%],cl jmp cse .under7 ;Set blue/green/red When r%<7 mov cl,pf%[ebx] mov [bl%],cl mov cl,pf%[ebx+1] mov [gr%],cl mov cl,pf%[ebx+2] mov [re%],cl .cse cmp al,1 ;Implements 'Case' Instruction je near cs17 cmp al,7 je near cs17 cmp al,2 je near cs28 cmp al,8 je near cs28 cmp al,3 je near cs39 cmp al,9 je near cs39 cmp al,4 je near cs410 cmp al,10 je near cs410 cmp al,5 je near cs511 cmp al,11 je near cs511 cmp al,6 je near cs612 cmp al,12 je near cs612 jmp past .cs17 ;Various Cases mov cl,[bl%] mov [bn%],cl mov cl,[gr%] mov [gn%],cl mov cl,[re%] mov [rn%],cl jmp past .cs28 mov cl,[gr%] mov [bn%],cl mov cl,[re%] mov [gn%],cl mov cl,[bl%] mov [rn%],cl jmp past .cs39 mov cl,[re%] mov [bn%],cl mov cl,[bl%] mov [gn%],cl mov cl,[gr%] mov [rn%],cl jmp past .cs410 mov cl,[bl%] mov [bn%],cl mov cl,[re%] mov [gn%],cl mov cl,[gr%] mov [rn%],cl jmp past .cs511 mov cl,[gr%] mov [bn%],cl mov cl,[bl%] mov [gn%],cl mov cl,[re%] mov [rn%],cl jmp past .cs612 mov cl,[re%] mov [bn%],cl mov cl,[gr%] mov [gn%],cl mov cl,[bl%] mov [rn%],cl jmp past ;End 0f Cases .past mov cl,[bn%] mov pfmir%[ebx],cl mov cl,[gn%] mov pfmir%[ebx+1],cl mov cl,[rn%] mov pfmir%[ebx+2],cl inc dword [^k%] mov edx,[^k%] cmp edx,[^wdth%] jl near kloop inc dword [^j%] mov edx,[^j%] cmp edx,[^hght%] jl near jloop ret ] endproc rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++