Home » Personal collection » Acorn hard disk » apps » !FastGrab » !RunImage
!RunImage
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Personal collection » Acorn hard disk » apps » !FastGrab |
Filename: | !RunImage |
Read OK: | ✔ |
File size: | 23C2A bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM > !RunImage 20debug%=FALSE 30PROCget_board_version 40ON ERROR ON ERROR OFF:PROCerror(0) 50version$="Version 2.00 (13th Oct 1992)" 60PROCinit 70ON ERROR PROCerror(-1) 80REPEAT 90PROCwimpservice(USR(pollcode),pb%) 100UNTIL FALSE 110END 120DEF PROCinit 130PROCsetvars 140taskhandle%=FNtaskinit("FastGrab") 150SYS "WVCGrab_Refresh",0 160PROCsetupwindows 170PROCfudgeinit 180IF NOT debug% VDU 21 190PROCassemble 200VDU 6 210A%=livearea%+60:B%=&20100:CALLblank 220PROCgetchoices 230PROCinstallonbar 240PROCmodechanged 250PROCcwin(3) 260PROCcwin(4) 270!rdb=w%(3,0):!udb=w%(3,0):!livewb=w%(3,0):livewb!4=livearea% 280!spritearea=livearea%:!spritead=livearea%+16 290!dragging%=0:!pollad=pb% 300REM PROCadjustlive 310PROCcalclive 320PROCshutlivedisplay 330SYS "Wimp_SlotSize",-1,-1 TO originalslot% 340ENDPROC 350 360DEF PROCround(RETURN value%,round%) 370IF (value% MOD round%)=0 ENDPROC 380value%=((value%+round%) DIV round%)*round% 390ENDPROC 400 410DEF PROCfudgeinit 420IF NOT debug% VDU 21 430PROCdolivecode 440PROCdograbcode 450VDU 6 460livename$="pic" 470dragtype%=-1 480nextlocation%=HIMEM 490DIM livearea% &20800 500!livearea%=&20700 510livearea%!4=1 520livearea%!8=16 530$(livearea%+20)="grabbed" 540livearea%!32=&3F 550livearea%!36=&7F 560livearea%!40=&00 570livearea%!44=&1F 580livearea%!48=&2C 590livearea%!52=&2C 600livearea%!56=15 610!livedumpad%=livearea%+60 620CALL set_8bit 630ENDPROC 640 650DEF PROCadd_palette_to_sprite(sprite_area%,sprite_ad%,sprite_pal%) 660LOCAL pal%,z% 670pal%=sprite_ad%+44 680sprite_ad%!32+=2048 690sprite_ad%!36+=2048 700sprite_ad%!00+=2048 710sprite_area%!12+=2048 720REM Bung a palette into the sprite area 730FORz%=0TO255 740 B%=(z%<<8) OR (z%<<16) OR (z%<<24) 750 pal%!(z%*8)=B%:pal%!(z%*8+4)=B% 760NEXT 770PROCpalette_for_sprite(sprite_area%,sprite_ad%,sprite_pal%) 780ENDPROC 790 800DEF PROClive_grey 810!livedumpad%=livearea%+60+2048 820old_sat%=saturation% 830saturation%=0 840$satad%="0" 850PROCsaturation 860PROCadd_palette_to_sprite(livearea%,livearea%+16,livepal%) 870PROCoptimise_liveplot 880ENDPROC 890 900DEF PROClive_colour 910saturation%=old_sat% 920$satad%=STR$(saturation%) 930PROCsaturation 940!livedumpad%=livearea%+60 950sptr%=livearea%+16 960sptr%!32-=2048 970sptr%!36-=2048 980sptr%!00-=2048 990livearea%!12-=2048 1000PROCpalette_for_sprite(livearea%,livearea%+16,livepal%) 1010PROCoptimise_liveplot 1020ENDPROC 1030 1040DEF PROCdograbcode 1050DIM GAP &2000,L% 0 1060FOR Pass%=8 TO 10 STEP 2 1070P%=GAP 1080[ 1090OPT Pass% 1100.VRAM_Grab 1110SWI 22 ; Into SVC mode 1120MOV R0,R15 1130ORR R0,R0,#3<<26 1140TEQP R15,R0 ; FIQ's off too... 1150 1160SWI "WVCGrab_MemBases" ; Get base of podule space 1170 1180LDRB R8,[R1] ; RAS only Refresh cycle 1190MOV R9,#0 1200 1210ORR r4,r1,#&1000 ; Page mode read cycle address 1220ORR r3,r1,#&1800 ; Terminate cycle address 1230ORR r2,r1,#&800 ; Initiate Read/SR to memory transfer 1240ORR r2,r2,#&008 ; VRAM address 8 1250ORR r7,r1,#&1000 ; Page mode read (CAS low) 1260ADD r7,r7,#&001C ; This gets around the pipelining issue 1270LDR R10,pagestep 1280LDR R11,pixelstep 1290.next_row_down 1300LDRB R8,[R2],R10 ; Initiate SR to memory transfer 1310;LDRB R8,[R7] ; Get a pixel from VRAM - fixes pipeline 1320SUB R7,R7,#16 1330.row_read 1340LDRB R8,[R7],R11 ; Get a pixel from VRAM 1350STRB R8,[R5],#1 ; Store it in the buffer 1360CMP R7,R3 ; End of the row reached? 1370BLT row_read 1380 1390SUB R7,R7,#&800 ; Do the next row down 1400ADD R7,R7,#&10 1410LDR R8,[R7,#&800] 1420CMP R2,R4 1430BLE next_row_down 1440TEQP R15,#0 1450MOVNV R6,R6 1460MOVS R15,R14 1470.pagestep 1480EQUD 8 1490.pixelstep 1500EQUD 4 1510 1520.mask EQUD 32767 1530 1540.read16bit 1550; r0=output address, r1=line number reqd 1560SWI "OS_EnterOS" 1570MOV r6,r0 ; Bung address for data (a line) into r6 1580MOV r0,r15 1590ORR r0,r0,#3<<26 ; Change processor mode 1600TEQP r15,r0 1610 1620LDR r3,packR3 1630LDR r4,packR4 1640LDR r5,packR5 1650MOV r0,#0 1660MOV r1,r1,LSL#3 ; Convert line number 1670LDR r8,[r3,r1] ; Initiate read cycle 1680 1690LDR r7,mask 1700 1710;LDR r8,[r4,r0,LSL#2] ; Get a pixel from the VRAM into r8 (16bit) 1720;ADD r0,r0,#1 1730 1740.get_another_byte 1750LDR r8,[r4,r0,LSL#2] ; Get a pixel from the VRAM into r8 (16bit) 1760 1770;MOV r8,#%11000<<10 ; Blue data 1780;ORR r8,r8,#%11101<<5 ; Green data 1790;ORR r8,r8,#%11000 ; Red data 1800 1810ADD r0,r0,#1 1820 1830AND r8,r8,r7 ; Get bottom fifteen bits 1840AND r9,r8,#&ff00 ; Get top byte from 15 bits 1850MOV r9,r9,LSR#8 1860STRB r8,[r6],#1 ; Store bottom byte in output buffer 1870STRB r9,[r6],#1 ; Store top byte in output buffer 1880CMP r0,#512 ; Did we read the full line yet? 1890BNE get_another_byte ; If not, get on with the job 1900LDR r8,[r5,#0] 1910TEQP r15,#0 1920MOVNV r0,R0 1930MOV r15,r14 1940 1950.packline 1960SWI "OS_EnterOS" 1970; r0=output address, r1=line number reqd 1980MOV R12,R0 ; Address for data (a line) 1990MOV R0,R15 2000ORR R0,R0,#3<<26 2010TEQP R15,R0 2020LDR R3,packR3 2030LDR R4,packR4 2040LDR R5,packR5 2050MOV R0,#0 2060MOV R1,R1,LSL#3 2070LDR R8,[R3,R1] ; Initiate read 2080.Next_Byte 2090LDR R8,[R4,R0,LSL #2] ; Get a pixel from the VRAM 2100ADD R0,R0,#1 ; Increment pixel counter 2110LDR R7,[R4,R0,LSL #2] ; Get a second pixel from the VRAM 2120ADD R0,R0,#1 ; Inc pixel ctr 2130AND R9,R8,#&F 2140AND R10,R7,#&F 2150ORR R11,R10,R9,LSL #4 2160STRB R11,[R12,#512] ; Bung byte into buffer 2170AND R9,R8,#&F0 2180AND R10,R7,#&F0 2190ORR R11,R9,R10,LSR #4 2200STRB R11,[R12,#256] ; Bung byte into buffer 2210AND R9,R8,#&F00 2220MOV R9,R9,LSR #4 2230AND R10,R7,#&F00 2240ORR R11,R9,R10,LSR #8 2250STRB R11,[R12],#1 ; Bung byte into buffer 2260CMP R0,#&200 ; Have we done a complete line yet? 2270BNE Next_Byte 2280LDR R8,[R5,#0] ; Terminate cycle 2290TEQP R15,#0 2300MOVNV R6,R6 2310MOV R15,R14 2320 2330.membaseR0 2340EQUD 0 2350.membaseR1 2360EQUD 0 2370.packR3 2380EQUD 0 2390.packR4 2400EQUD 0 2410.packR5 2420EQUD 0 2430 2440.set_8bit 2450SWI 22 2460SWI "WVCGrab_MemBases" 2470ADD R0,R0,#&2000 ; &2000=Paging reg for V9 Mk I 2480MOV R1,#&10 2490STRB R1,[R0] 2500ADD r0,r0,#&1000 ; &3000=Paging reg for V9 Mk II 2510STRB R1,[R0] 2520 2530TEQP R15,#0 2540MOVNV R0,R0 2550MOVS R15,R14 2560.set_12bit 2570SWI 22 2580SWI "WVCGrab_MemBases" 2590ADD R0,R0,#&2000 ; &2000=Paging reg for V9 Mk I 2600MOV R1,#0 2610STRB R1,[R0] 2620ADD r0,r0,#&1000 ; &3000=Paging reg for V9 Mk II 2630STRB R1,[R0] 2640TEQP R15,#0 2650MOVNV R0,R0 2660MOVS R15,R14 2670 2680.Refresh_Frame 2690SWI 22 2700SWI "WVCGrab_MemBases" 2710ADD R0,R1,#&1800 2720LDR R2,[R1,#0] 2730MOV R0,#256 2740.Refresh_Loop 2750LDR R2,[R1,R0] ; Refresh Cycle 2760SUBS R0,R0,#1 2770BNE Refresh_Loop 2780TEQP R15,#0 2790MOVNV R0,R0 2800MOVS R15,R14 2810 2820] 2830NEXT Pass% 2840SYS "WVCGrab_MemBases" TO r0,r1 2850!packR3=r1 OR &800 2860!packR4=r1 OR &1000 2870!packR5=r1 OR &1800 2880ENDPROC 2890 2900DEF PROCdolivecode 2910DIM livegap% &1200,L% 0 2920FOR pass%=8 TO 10 STEP 2 2930P%=livegap% 2940[ 2950OPT pass% 2960.live_grab 2970SWI 22 ; Interrupts off 2980MOV R0,R15 2990ORR R0,R0,#3<<26 3000TEQP R15,R0 ; Turn off fast interrupts too (sorry...) 3010LDR R1,livebaseR1 ; Get base of podule space 3020LDR R5,livedumpad% ; Get address for 8bpp output 3030ORR R2,R1,#&1000 ; Page mode read cycle address 3040ORR R6,R1,#&800 ; Initiate pixel read cycle address 3050MOV R9,#&1800 ; Terminate cycle address 3060 3070MOV R11,#0 3080 3090.livefield_poll 3100LDR R8,[R6] ; Start pixel read cycle 3110LDR R8,[R1,R9] ; Terminate read cycle 3120ADD R11,R11,#1 ; Increment counter 3130CMP R11,#&8000 ; Too many tries? 3140BGT signalgone ; If not, complain... 3150TST r8,#&4000 ; Video signal present? 3160BEQ livefield_poll ; If no signal, wait for a while 3170MOV R11,#0 3180 3190MOV R11,#1 3200.livevert_poll 3210LDR R8,[R6] ; Start pixel read cycle 3220LDR R8,[R1,R9] ; Terminate read cycle 3230ADD R11,R11,#1 ; Increment counter 3240CMP R11,#&8000 ; How long... 3250BGT signalgone 3260TST R8,#&2000 3270BEQ livevert_poll 3280 3290MOV R11,#0 3300.livevert_poll1 3310LDR R8,[R6] ; Start pixel read 3320LDR R8,[R1,R9] ; Terminate pixel read 3330ADD R11,R11,#1 ; Inc counter 3340CMP R11,#&8000 ; Too many yet? 3350BGT signalgone 3360TST R8,#&2000 3370BNE livevert_poll1 3380 3390LDR R8,[R1] ; Read word from VRAM 3400LDR R12,fielding ; Grabbing single field at the moment? 3410CMP R12,#0 3420BEQ bothfields ; If not, don't care which field this is 3430LDR R11,evenfield ; Otherwise, find out which field is required 3440MOV R11,R11,LSL #14 3450AND R12,R8,#1<<14 3460CMP R12,R11 ; Is this the field to do? 3470BEQ bothfields ; If so, grab it 3480B livefield_poll ; Otherwise, wait for the next frame... 3490 3500.bothfields 3510STR R8,[R6] ; Start SR to memory transfer 3520STR R8,[R1,R9] ; Terminate transfer cycle 3530STR R8,[R1] ; RAS only refresh, to allow serial VRAM transfer 3540MOV R10,#&1000 3550MOV R12,#0 3560 3570.livenext_row 3580MOV r0,#0 3590 3600.liveEnd_Blank ; Wait for the end blank signal 3610LDR R8,[R6] ; Start pixel read cycle 3620 3630LDR R8,[R1,R9] ; Terminate cycle 3640 3650ADD R0,R0,#1 ; Increment row counter 3660CMP R0,#&8000 3670BGT signalgone 3680TST R8,#&1000 ; Blank signal found? 3690BEQ liveEnd_Blank 3700 3710MOV R11,#0 3720.liverow_data_in ; Read data into VRAM 3730LDR R8,[R6] ; Start read cycle 3740LDR R8,[R1,R9] ; Terminate read cycle 3750ADD R11,R11,#1 3760CMP R11,#&8000 3770BGT signalgone 3780TST R8,#&1000 3790BNE liverow_data_in 3800 3810STRB R8,[R6],#8 ; Pass VRAM address to V9 and start read cycle 3820STRB R8,[R1,R9] ; Terminate read cycle 3830CMP R6,R2 ; Read 512*16bit words into VRAM yet? 3840BLT livenext_row ; If not, get the next row !!! 3850ORR R4,R1,#&1000 3860ORR R3,R1,#&1800 3870ORR R2,R1,#&800 ; Cycle type 2a 3880ORR R2,R2,#8 ; VRAM Address &08 3890ORR R7,R1,#&1000 ; Page mode read cycle 3900ORR R7,R7,#&20 ; VRAM Address &14 at the start 3910 3920LDR R10,livepagestep 3930LDR R11,livepixelstep 3940 3950ADD r9,r1,#&2000 ; Paging register address 3960ADD r12,r1,#&3000 3970 3980.livenext_row_down 3990;MOV r0,#1<<6 ; Bit 6 controls hardware dithering 4000;STR r0,[r12] ; Store in paging reg 4010;STR r0,[r9] 4020;MOV r0,#0 4030;STR r0,[r12] 4040;STR r0,[r9] 4050 4060LDRB R8,[R2],R10 ; Initiate read cycle for next line 4070SUB R7,R7,#16 ; Decrement page mode read counter 4080 4090.liverow_read 4100LDRB R8,[R7],R11 ; Do page mode read to scan the line 4110STRB R8,[R5],#1 ; Put the 8bpp data into the live buffer 4120CMP R7,R3 ; Read a whole line yet? 4130BLT liverow_read ; If not, get another pixel 4140 4150SUB R7,R7,#&800 ; Decrement page mode counter 4160ADD R7,R7,#&10 4170LDR R8,[R7,#&800] ; Set page mode address 4180CMP R2,R4 ; Read 256 lines yet? 4190BLT livenext_row_down; If not, get another line !!! 4200LDR R0,signalpresent 4210CMP R0,#0 4220BEQ signalback 4230TEQP R15,#0 4240MOVNV R0,R0 4250MOVS PC,R14 4260.signalback 4270MOV R0,#1 4280STR R0,signalpresent 4290MOV R0,#0 4300SWI "WVCGrab_Refresh" ; Turns refresh off, signal is back 4310ADR R7,signal 4320B udicon 4330.signalgone 4340LDR R0,signalpresent 4350CMP R0,#0 4360BNE changeicon 4370TEQP R15,#0 4380MOVNV R6,R6 4390MOVS PC,R14 4400.changeicon 4410MOV R0,#0 4420STR R0,signalpresent 4430MOV R0,#1 4440SWI "WVCGrab_Refresh" ; Turns refresh on, signal has gone 4450ADR R7,nosignal 4460.udicon 4470LDMIA R7,{R1-R3} 4480ADR R7,barspace 4490STMIA R7,{R1-R3} 4500ADR R1,iconb 4510SWI "Wimp_SetIconState" 4520TEQP R15,#0 4530MOVNV R6,R6 4540MOVS PC,R14 4550.signal 4560EQUS "barsignal"+CHR$0+CHR$0 4570ALIGN 4580.nosignal 4590EQUS "barnosignal" 4600EQUB 0 4610ALIGN 4620.signalpresent 4630EQUD 1 4640.barspace 4650EQUS "barsignal" 4660EQUB 0 4670ALIGN 4680.livebaseR1 4690EQUD 0 4700.fielding 4710EQUD 0 4720.evenfield 4730EQUD 1 4740.livedumpad% 4750EQUD 0 4760.livepagestep 4770EQUD 16 4780.livepixelstep 4790EQUD 8 4800.iconb 4810EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 4820EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 4830EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 4840EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 4850EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 4860] 4870NEXT pass% 4880SYS "WVCGrab_MemBases" TO ,r1 4890!livebaseR1=r1 4900ENDPROC 4910 4920DEF PROCsetvars 4930longsp%=8400 4940templatespace%=8096 4950maxmenusize%=1000 4960DIM block% 4,pb% 2048,iconsp% templatespace%,mouseb% 20,menub% 10000,longitems% longsp%,mb% 30048,magt% 32,livepal% 256,grabpal% 256,modeb% 100 4970liveplot%=liveplot% 4980tempsize%=8000 4990DIM tempb% tempsize%,w%(17,2) 5000DIM IICblock% 10 5010ctempb%=tempb% 5020$(modeb%+4)="a0-9"+CHR$0 5030submode$="Mode|*modeb%,modeb%+4,4|" 5040FOR set%=0 TO 28 STEP 4 5050magt%!set%=1 5060NEXT 5070$block%="TASK" 5080wksp%=iconsp% 5090spnd%=iconsp%+templatespace% 5100close%=FALSE 5110quitting%=FALSE 5120quithand%=0 5130scrappy%=FALSE 5140saved8%=TRUE 5150saved12%=TRUE 5160oldmode%=MODE 5170live%=TRUE 5180grabex%=FALSE 5190cfsid%=FALSE 5200oldmenu%=-1 5210slave%=FALSE 5220qflag%=FALSE 5230c%=FALSE 5240ENDPROC 5250DEF FNtaskinit(task$) 5260SYS "Wimp_Initialise",200,!block%,task$ TO wimpversion%,taskhandle% 5270=taskhandle% 5280DEF PROCsetupwindows 5290LOCAL os% 5300sh%=OPENIN("<FastGrab$Dir>.Resources.Sprites") 5310IF sh%=0 ERROR 214,"Sprite file cannot be found" 5320DIM sprites% EXT#sh%+16 5330!sprites%=EXT#sh%+16 5340sprites%!4=0 5350sprites%!8=16 5360sprites%!12=16 5370CLOSE#sh% 5380SYS "OS_SpriteOp",266,sprites%,"<FastGrab$Dir>.Resources.Sprites" 5390SYS "Wimp_OpenTemplate",,"<FastGrab$Dir>.Resources.Templates" 5400PROCltemp("Parameters",w%(1,1),0):REM Change 0 to -1 for new icons! 5410modead%=FNiconad(1,0) 5420x1ad%=FNiconad(1,1) 5430x2ad%=FNiconad(1,2) 5440y1ad%=FNiconad(1,3) 5450y2ad%=FNiconad(1,4) 5460sharpenad%=FNiconad(1,22) 5470blackad%=FNiconad(1,30) 5480gammaad%=FNiconad(1,31) 5490PROCltemp("PALWindow",w%(2,1),0) 5500brightad%=FNiconad(2,3) 5510contad%=FNiconad(2,8) 5520satad%=FNiconad(2,13) 5530PROCltemp("LiveWin",w%(3,1),0) 5540w%(3,1)?39=&FF 5550PROCltemp("LivePane",w%(4,1),0) 5560w%(4,1)!68=sprites% 5570w%(4,1)!(88+4+16+32*1)=w%(4,1)!(88+4+16+32*1) OR 1<<22 5580IF (board_is_16_bit%=FALSE AND allow_dithering%=FALSE) THEN w%(4,1)!(88+4+16+32*4)=w%(4,1)!(88+4+16+32*4) OR 1<<22 5590valid%=!(w%(4,1)+88+4+24+32*3) 5600IF board_is_16_bit% THEN 5610 $valid%="stb_16bit,tb_8bit" 5620ELSE 5630 $valid%="stb_12bit,tb_8bit" 5640ENDIF 5650PROCltemp("8BitShow",w%(5,1),0) 5660w%(5,1)?39=&FF 5670grabwtitlead%=wksp%-255 5680PROCltemp("GrabPane",w%(6,1),0) 5690w%(6,1)!68=sprites% 5700PROCltemp("SprSaveWin",w%(7,1),0) 5710outsprad%=FNiconad(7,2) 5720PROCltemp("RawSaveWin",w%(8,1),0) 5730outrawad%=FNiconad(8,2) 5740PROCltemp("Magnifier",w%(9,1),0) 5750mag1ad%=FNiconad(9,0):$mag1ad%="1" 5760mag2ad%=FNiconad(9,1):$mag2ad%="1" 5770PROCltemp("SpriteInfo",w%(10,1),0) 5780grabnamead%=FNiconad(10,0) 5790grabmodead%=FNiconad(10,1) 5800grabmaskad%=FNiconad(10,2) 5810grabwidtad%=FNiconad(10,3) 5820grabbytead%=FNiconad(10,4) 5830grabpalad%=FNiconad(10,5) 5840grabheigad%=FNiconad(10,6) 5850PROCltemp("RawInfo",w%(11,1),0) 5860rawbytesad%=FNiconad(11,1) 5870rawwidthad%=FNiconad(11,3) 5880rawheightad%=FNiconad(11,5) 5890rawbrightad%=FNiconad(11,9) 5900rawcontad%=FNiconad(11,11) 5910rawsatad%=FNiconad(11,10) 5920PROCltemp("Info",w%(13,1),-1) 5930$FNiconad(13,7)=version$ 5940PROCltemp("ImageInfo",w%(14,1),0) 5950$FNiconad(14,4)=FNChangeFSIVersion 5960PROCltemp("Query",w%(15,1),0) 5970queryad%=FNiconad(15,1) 5980PROCltemp("SpeedWin",w%(17,1),0) 5990speedad%=FNiconad(17,3) 6000SYS"Wimp_CloseTemplate" 6010ENDPROC 6020 6030DEF FNiconad(wh%,ih%) 6040=!(w%(wh%,1)+112+ih%*32) 6050 6060DEF PROCltemp(tempname$,RETURN address%,indirected%) 6070SYS "Wimp_LoadTemplate",,ctempb%+4,wksp%,spnd%,-1,tempname$,0 TO ,,wksp%,,,,found% 6080IF found%=0 SYS "Wimp_CloseTemplate":ERROR 0,"Template file is incorrect" 6090address%=ctempb% 6100IF (ctempb%-tempb%+tempsize%<400) ERROR 0,"Templates need more space" 6110ctempb%+=4+88+ctempb%!88*32 6120IF indirected% address%!68=sprites% 6130ENDPROC 6140DEF PROCgetchoices 6150inc%=OPENIN("<FastGrab$Dir>.Resources.Choices") 6160IF inc%=0 THEN 6170$modead%="15" 6180$x1ad%="1" 6190$x2ad%="1" 6200$y1ad%="1" 6210$y2ad%="1" 6220outmode$=" " 6230PROCsetflags(0) 6240$sharpenad%="" 6250contrast%=32 6260savedcont%=32 6270saturation%=32 6280old_sat%=saturation% 6290savedsat%=32 6300brightness%=0 6310savedbright%=0 6320bit%=12 6330dithered%=1 6340IF board_is_16_bit% OR allow_dithering% THEN 6350 dither$=">" 6360ELSE 6370 dither$="<" 6380ENDIF 6390IF allow_mono% THEN 6400 mono$="" 6410ELSE 6420 mono$="<" 6430ENDIF 6440ltool$=">" 6450gtool$=">" 6460speed%=99 6470field$="" 6480!fielding=0 6490!evenfield=0 6500PROCfieldmenu 6510cache$="" 6520$modeb%="15" 6530grabsize%=0 6540livesize%=2 6550PROCselect(26,0) 6560PROCselect(27,0) 6570PROCselect(28,0) 6580$blackad%="32" 6590PROCselect(29,0) 6600$gammaad%="2.2" 6610ELSE 6620mode%=BGET#inc% 6630$modead%=STR$mode% 6640INPUT#inc%,$x1ad% 6650INPUT#inc%,$y1ad% 6660INPUT#inc%,$x2ad% 6670INPUT#inc%,$y2ad% 6680options%=BGET#inc% OR (BGET#inc%)<<8 6690PROCsetflags(options%) 6700$sharpenad%=STR$(BGET#inc%) 6710brightness%=BGET#inc% 6720savedbright%=brightness% 6730contrast%=BGET#inc% 6740savedcont%=contrast% 6750saturation%=BGET#inc% 6760savedsat%=saturation% 6770old_sat%=saturation% 6780tool%=BGET#inc% 6790IF (tool% AND 1) bit%=12 ELSE bit%=8 6800IF (tool% AND 2) ltool$=">" ELSE ltool$="" 6810IF (tool% AND 4) gtool$=">" ELSE gtool$="" 6820IF (tool% AND 8) cache$=">" ELSE cache$="" 6830IF (tool% AND 16) field$=">":!fielding=1 ELSE field$="":!fielding=0 6840!evenfield=(tool% AND 32)>>4 6850IF (tool% AND 128) mono$=">" ELSE mono$="" 6860IF allow_mono%=FALSE THEN mono$="<" 6870IF board_is_16_bit% THEN 6880 IF (tool% AND 64) THEN dithered%=1:dither$=">" ELSE dithered%=0:dither$="" 6890 PROCchange_LCA(dithered%) 6900ELSE 6910 SYS "WVCGrab_LCA",0 6920 CALL set_8bit 6930 IF allow_dithering% THEN 6940 dithered%=1 6950 dither$=">" 6960 ELSE 6970 dithered%=0 6980 dither$="<" 6990 ENDIF 7000ENDIF 7010old_sat%=saturation% 7020PROCfieldmenu 7030speed%=BGET#inc% 7040modeval%=BGET#inc%:$modeb%=STR$modeval% 7050grabsize%=BGET#inc% 7060livesize%=BGET#inc% 7070sel%=BGET#inc%:IF sel% PROCselect(26,1) 7080sel%=BGET#inc%:IF sel% PROCselect(27,1) 7090sel%=BGET#inc%:IF sel% PROCselect(28,1) 7100$blackad%=STR$(BGET#inc%) 7110sel%=BGET#inc%:IF sel% PROCselect(29,1) 7120INPUT#inc%,$gammaad% 7130precise%=BGET#inc% 7140IF precise% THEN 7150 on%=32:outmode$="P" 7160 FOR s%=7 TO 32 7170 IF s%=on% PROCiconset(1,s%,1<<21,1<<21) ELSE PROCiconset(1,s%,1<<21,0) 7180 NEXT 7190ENDIF 7200CLOSE#inc% 7210ENDIF 7220grabsize$=FNsetsizemenu(grabsize%) 7230livesize$=FNsetsizemenu(livesize%) 7240PROCspeed:$speedad%=STR$speed% 7250PROCcontrast:$contad%=STR$contrast% 7260PROCbrightness:$brightad%=STR$brightness% 7270PROCsaturation:$satad%=STR$saturation% 7280IF bit%=12 THEN 7290 PROCiconset(4,3,1<<21,0) 7300ELSE 7310 PROCiconset(4,3,1<<21,1<<21) 7320ENDIF 7330ENDPROC 7340DEF PROCsetflags(set%) 7350IF set% AND 256 THEN 7360PROCiconset(1,6,1<<21,0) 7370PROCiconset(1,5,1<<21,1<<21) 7380ELSE 7390PROCiconset(1,6,1<<21,1<<21) 7400PROCiconset(1,5,1<<21,0) 7410ENDIF 7420CASE set% AND 3 OF 7430WHEN 0 7440 outmode$=" " 7450 on%=7 7460WHEN 1 7470 outmode$="C" 7480 on%=8 7490WHEN 2 7500 outmode$="D" 7510 on%=9 7520WHEN 3 7530 outmode$="T" 7540 on%=10 7550ENDCASE 7560FOR s%=7 TO 32 7570 IF s%=on% PROCiconset(1,s%,1<<21,1<<21) ELSE PROCiconset(1,s%,1<<21,0) 7580NEXT 7590PROCselect(11,(set% AND 4)>>2) 7600PROCselect(12,(set% AND 8)>>3) 7610PROCselect(13,(set% AND 16)>>4) 7620PROCselect(14,(set% AND 32)>>5) 7630PROCselect(15,(set% AND 64)>>6) 7640PROCselect(16,(set% AND 128)>>7) 7650PROCselect(23,(set% AND 512)>>9) 7660PROCselect(24,(set% AND 1024)>>10) 7670PROCselect(25,(set% AND 2048)>>11) 7680PROCselect(27,(set% AND 4096)>>12) 7690ENDPROC 7700 7710DEF PROCselect(icon%,select%) 7720PROCiconset(1,icon%,1<<21,select%<<21) 7730ENDPROC 7740 7750DEF PROCwimpservice(event%,pb%) 7760CASE event% OF 7770WHEN 0 7780 CASE !dragging% OF 7790 WHEN 1,2,3 7800 PROCdopaldrag 7810 WHEN 4 7820 PROCdospeeddrag 7830 ENDCASE 7840WHEN 1 7850 PROCredrawwin 7860WHEN 2 7870 CASE !pb% OF 7880 WHEN w%(3,0) 7890 PROCdopane(w%(3,0)) 7900 WHEN w%(5,0) 7910 PROCdopane(w%(5,0)) 7920 OTHERWISE 7930 SYS "Wimp_OpenWindow",,pb% 7940 ENDCASE 7950WHEN 3 7960 CASE !pb% OF 7970 WHEN w%(3,0) 7980 PROCshutlivedisplay 7990 WHEN w%(5,0) 8000 PROCdwin(5) 8010 !grabwb=0 8020 IF gtool$=">" PROCdwin(6) 8030 OTHERWISE 8040 SYS "Wimp_DeleteWindow",,pb% 8050 w%(FNwindowid(!pb%),2)=FALSE 8060 ENDCASE 8070WHEN 6 8080 PROCclickwindow 8090WHEN 7 8100 PROCdragend 8110WHEN 8 8120 PROChandlekey 8130WHEN 9 8140 PROCmenuselect 8150WHEN 17,18 8160 PROCmessage 8170ENDCASE 8180ENDPROC 8190 8200DEF PROCshutlivedisplay 8210PROCdwin(3) 8220!livewb=0 8230IF ltool$=">" PROCdwin(4) 8240live%=FALSE 8250!maskad=%1100000110001 8260IF !signalpresent $barspace="bardorms" ELSE $barspace="bardormn" 8270!mb%=-1 8280mb%!4=iconbar% 8290mb%!8=0 8300mb%!12=0 8310SYS "Wimp_SetIconState",,mb% 8320ENDPROC 8330 8340DEF FNdumpsprite 8350$(mb%+4)="Sprite not saved - discard it?" 8360SYS "Wimp_ReportError",mb%,7,"FastGrab" TO ,response% 8370IF response%=2 =FALSE ELSE =TRUE 8380 8390DEF PROCshutdown(arg%) 8400IF arg% THEN 8410 IF NOT saved12% AND (debug%=FALSE) THEN 8420 PROCquery(2,"Image not saved in FastGrab: are you sure you want to quit?") 8430 ENDPROC 8440 ENDIF 8450 IF slave% THEN 8460 $mb%="<FastGrab$Dir>.Resources.TwelveBit" 8470 SYS "OS_FSControl",27,mb%,,0 8480 slave%=FALSE 8490 ENDIF 8500ENDIF 8510close%=TRUE 8520IF quitting% THEN 8530 SYS "Wimp_GetCaretPosition",,mb% 8540 mb%!24=&1FC 8550 SYS "Wimp_SendMessage",8,mb%,0 8560 SYS "Wimp_SendMessage",8,mb%,quithand% 8570ENDIF 8580SYS "Wimp_CloseDown",taskhandle%,"TASK" 8590END 8600ENDPROC 8610 8620DEF PROCquery(qnum%,message$) 8630qflag%=qnum% 8640$queryad%=message$ 8650PROCmenu(15,rightscr%/2-738/2,topscr%/2+276/2,0) 8660ENDPROC 8670 8680DEF PROCredrawwin 8690CASE !pb% OF 8700WHEN w%(2,0) 8710 SYS "Wimp_RedrawWindow",,pb% TO more% 8720 x0%=pb%!4-pb%!20 8730 y0%=pb%!16-pb%!24 8740 WHILE more% 8750 CLG 8760 SYS "Wimp_SetColour",7 8770 RECTANGLE FILL x0%+140,y0%-36,brightness%*4,20 8780 RECTANGLE FILL x0%+140,y0%-80,contrast%*4,20 8790 RECTANGLE FILL x0%+140,y0%-124,saturation%*4,20 8800 SYS "Wimp_GetRectangle",,pb% TO more% 8810 ENDWHILE 8820WHEN w%(17,0) 8830 SYS "Wimp_RedrawWindow",,pb% TO more% 8840 x0%=pb%!4-pb%!20 8850 y0%=pb%!16-pb%!24 8860 WHILE more% 8870 CLG 8880 SYS "Wimp_SetColour",7 8890 RECTANGLE FILL x0%+140,y0%-36,speed%*2,20 8900 SYS "Wimp_GetRectangle",,pb% TO more% 8910 ENDWHILE 8920ENDCASE 8930ENDPROC 8940 8950DEF PROCdopane(toolwindow%) 8960CASE toolwindow% OF 8970WHEN w%(3,0) 8980 pane%=w%(4,0) 8990 paneopen%=(ltool$=">") 9000WHEN w%(5,0) 9010 pane%=w%(6,0) 9020 paneopen%=(gtool$=">") 9030OTHERWISE 9040 ERROR 100,"This window is paneless!" 9050ENDCASE 9060!mb%=toolwindow% 9070SYS "Wimp_GetWindowState",,mb% 9080IF mb%!32 AND 1<<19 THEN 9090 PROCtogglewindowsize(mb%) 9100 SYS "Wimp_OpenWindow",,pb% 9110 SYS "Wimp_GetWindowState",,pb% 9120ENDIF 9130IF pb%!4<=mb%!4 towards%=TRUE ELSE towards%=FALSE 9140!mb%=pane% 9150mb%!4=pb%!4-88 9160mb%!8=pb%!8 9170mb%!12=pb%!4-4 9180mb%!16=pb%!16 9190mb%!20=0 9200mb%!24=0 9210mb%!28=pb%!28 9220IF towards% THEN 9230 IF paneopen% THEN 9240 SYS "Wimp_OpenWindow",,mb% 9250 pb%!28=pane% 9260 ENDIF 9270 SYS "Wimp_OpenWindow",,pb% 9280ELSE 9290 SYS "Wimp_OpenWindow",,pb% 9300 IF paneopen% SYS "Wimp_OpenWindow",,mb% 9310ENDIF 9320ENDPROC 9330 9340DEF PROCtogglewindowsize(block%) 9350win%=FNwindowid(!block%) 9360REM IF w%(win%,1)!44<-rightscr% THEN 9370REM block%!4=0 9380REM block%!12=rightscr%-48 9390REM ENDIF 9400REM IF w%(win%,1)!56>topscr% THEN 9410REM block%!8=48 9420REM block%!16=topscr%-48 9430REM ENDIF 9440block%!12=block%!4+w%(win%,1)!52 9450block%!8=block%!16-w%(win%,1)!56 9460ENDPROC 9470 9480DEF FNwindowid(handle%) 9490LOCAL win% 9500win%=0 9510WHILE w%(win%,0)<>handle% 9520 win%+=1 9530ENDWHILE 9540=win% 9550 9560DEF PROCclickwindow 9570 9580adjust%=pb%!4 AND 1 9590 9600CASE pb%!12 OF 9610 9620WHEN -2 9630 CASE pb%!16 OF 9640 WHEN iconbar% 9650 CASE pb%!8 OF 9660 WHEN 2 9670 mousex%=!pb% 9680 mousey%=186 9690 menu%=FNcmenu(0,"FastGrab|@13'Info|Quit|",96) 9700 mentype%=0 9710 WHEN 4 9720 IF NOT live% THEN 9730 w%(3,1)!4=rightscr%/2-livex%/2 9740 w%(3,1)!8=topscr%/2-livey%/2 9750 w%(3,1)!12=rightscr%/2+livex%/2 9760 w%(3,1)!16=topscr%/2+livey%/2 9770 IF w%(3,1)!8<0 w%(3,1)!8=84 9780 w%(3,1)!20=0 9790 w%(3,1)!24=0 9800 w%(3,1)!28=-1 9810 PROCcwin(3) 9820 !rdb=w%(3,0) 9830 !udb=w%(3,0) 9840 !livewb=w%(3,0) 9850 SYS "Wimp_OpenWindow",,w%(3,1) 9860 IF ltool$=">" THEN 9870 w%(4,1)!4=w%(3,1)!4-88 9880 w%(4,1)!8=w%(3,1)!8 9890 w%(4,1)!12=w%(4,1)!4+84 9900 w%(4,1)!16=w%(3,1)!16 9910 w%(4,1)!28=-1 9920 IF grabex% PROCiconset(4,1,1<<22,0) 9930 PROCcwin(4) 9940 SYS "Wimp_OpenWindow",,w%(4,1) 9950 ENDIF 9960 IF !signalpresent THEN $barspace="barsignal" ELSE $barspace="barnosignal" 9970 !mb%=-1 9980 mb%!4=iconbar% 9990 mb%!8=0 10000 mb%!12=0 10010 SYS "Wimp_SetIconState",,mb% 10020 live%=TRUE 10030 !maskad=%1100000110000 10040 ELSE 10050 IF ltool$=">" THEN 10060 !mb%=w%(4,0) 10070 SYS "Wimp_GetWindowState",,mb% 10080 mb%!28=-1 10090 SYS "Wimp_OpenWindow",,mb% 10100 !mb%=w%(3,0) 10110 SYS "Wimp_GetWindowState",,mb% 10120 mb%!28=w%(4,0) 10130 SYS "Wimp_OpenWindow",,mb% 10140 ELSE 10150 !mb%=w%(3,0) 10160 SYS "Wimp_GetWindowState",,mb% 10170 mb%!28=-1 10180 SYS "Wimp_OpenWindow",,mb% 10190 ENDIF 10200 ENDIF 10210 ENDCASE 10220ENDCASE 10230 10240WHEN w%(3,0) 10250 CASE pb%!8 OF 10260 WHEN 2 10270 PROClivemenu 10280 ENDCASE 10290 10300WHEN w%(4,0) 10310 IF (pb%!8 AND 4) THEN 10320 CASE pb%!16 OF 10330 WHEN 0 10340 PROCgrab 10350 PROCshowgrab 10360 WHEN 1 10370 PROCshowgrab 10380 WHEN 2 10390 PROCmenu(2,!pb%-290,pb%!4+68,0) 10400 WHEN 3 10410 IF bit%=12 bit%=8 ELSE bit%=12 10420 WHEN 4 10430 dithered%=dithered% EOR 1 10440 PROCchange_LCA(dithered%) 10450 ENDCASE 10460 ENDIF 10470 IF (pb%!8 AND 2) PROClivemenu 10480 10490WHEN w%(5,0) 10500 CASE pb%!8 OF 10510 WHEN 2 10520 PROCgrabmenu 10530 ENDCASE 10540WHEN w%(6,0) 10550 IF (pb%!8 AND 4) THEN 10560 CASE pb%!16 OF 10570 WHEN 0 10580 PROCmenu(1,!pb%-354,pb%!4+264,0) 10590 WHEN 1 10600 PROCmenu(9,!pb%-136,pb%!4+64,0) 10610 WHEN 2 10620 PROCmenu(7,!pb%-122,pb%!4+84,0) 10630 dragtype%=0 10640 WHEN 3 10650 PROCmenu(8,!pb%-122,pb%!4+84,0) 10660 dragtype%=1 10670 ENDCASE 10680 ENDIF 10690 IF (pb%!8 AND 2) PROCgrabmenu 10700 10710WHEN w%(9,0) 10720 IF (pb%!8 AND 1)=0 THEN 10730 CASE pb%!16 OF 10740 WHEN 2 10750 PROCmagstring(1,0) 10760 WHEN 3 10770 PROCmagstring(-1,0) 10780 WHEN 4 10790 PROCmagstring(0,1) 10800 WHEN 5 10810 PROCmagstring(0,-1) 10820 ENDCASE 10830 ELSE 10840 CASE pb%!16 OF 10850 WHEN 2 10860 PROCmagstring(-1,0) 10870 WHEN 3 10880 PROCmagstring(1,0) 10890 WHEN 4 10900 PROCmagstring(0,-1) 10910 WHEN 5 10920 PROCmagstring(0,1) 10930 ENDCASE 10940 ENDIF 10950 10960WHEN w%(7,0) 10970 CASE pb%!16 OF 10980 WHEN 1 10990 PROCsavesprite 11000 WHEN 0 11010 IF (pb%!8 AND &50)<>0 THEN 11020 PROCgst(pb%,w%(7,0)) 11030 !mb%=w%(7,0) 11040 mb%!4=0 11050 SYS "Wimp_GetIconState",,mb% 11060 ilx%=mb%!8:ity%=mb%!12 11070 irx%=mb%!16:iby%=mb%!20 11080 PROCgst(mb%,w%(7,0)) 11090 !pb%=w%(7,0) 11100 pb%!4=5 11110 pb%!8=mb%!4+ilx% 11120 pb%!12=mb%!16+ity% 11130 pb%!16=mb%!4+irx% 11140 pb%!20=mb%!16+iby% 11150 pb%!24=0 11160 pb%!28=0 11170 pb%!32=&7FFFFFFF 11180 pb%!36=&7FFFFFFF 11190 SYS "Wimp_DragBox",,pb% 11200 dragtype%=0 11210 ENDIF 11220 ENDCASE 11230 11240WHEN w%(8,0) 11250 CASE pb%!16 OF 11260 WHEN 1 11270 PROCsaveraw 11280 WHEN 0 11290 IF (pb%!8 AND &50)<>0 THEN 11300 PROCgst(pb%,w%(8,0)) 11310 !mb%=w%(8,0) 11320 mb%!4=0 11330 SYS "Wimp_GetIconState",,mb% 11340 ilx%=mb%!8:ity%=mb%!12 11350 irx%=mb%!16:iby%=mb%!20 11360 PROCgst(mb%,w%(8,0)) 11370 !pb%=w%(8,0) 11380 pb%!4=5 11390 pb%!8=mb%!4+ilx% 11400 pb%!12=mb%!16+ity% 11410 pb%!16=mb%!4+irx% 11420 pb%!20=mb%!16+iby% 11430 pb%!24=0 11440 pb%!28=0 11450 pb%!32=&7FFFFFFF 11460 pb%!36=&7FFFFFFF 11470 SYS "Wimp_DragBox",,pb% 11480 dragtype%=1 11490 ENDIF 11500 ENDCASE 11510 11520WHEN w%(1,0) 11530 CASE pb%!16 OF 11540 WHEN 7 11550 outmode$=" " 11560 WHEN 8 11570 outmode$="C" 11580 WHEN 9 11590 outmode$="D" 11600 WHEN 10 11610 outmode$="T" 11620 WHEN 32 11630 outmode$="P" 11640 WHEN 25 11650 SYS "Wimp_CreateMenu",,-1 11660 PROCgocfsi 11670 ENDCASE 11680 IF (pb%!8 AND 1) AND (pb%!16<11) PROCiconset(1,pb%!16,1<<21,1<<21) 11690 11700WHEN w%(2,0) 11710 adjust%=pb%!8 AND 1 11720 ch%=FALSE 11730 CASE pb%!16 OF 11740 WHEN 1 11750 IF adjust% THEN 11760 IF brightness%<>0 brightness%-=1:ch%=TRUE 11770 ELSE 11780 IF brightness%<>63 brightness%+=1:ch%=TRUE 11790 ENDIF 11800 IF ch% $brightad%=STR$brightness%:PROCudpbar(-36,brightness%) 11810 WHEN 2 11820 IF adjust% THEN 11830 IF brightness%<>63 brightness%+=1:ch%=TRUE 11840 ELSE 11850 IF brightness%<>0 brightness%-=1:ch%=TRUE 11860 ENDIF 11870 IF ch% $brightad%=STR$brightness%:PROCudpbar(-36,brightness%) 11880 WHEN 6 11890 IF adjust% THEN 11900 IF contrast%<>0 contrast%-=1:ch%=TRUE 11910 ELSE 11920 IF contrast%<>63 contrast%+=1:ch%=TRUE 11930 ENDIF 11940 IF ch% $contad%=STR$contrast%:PROCudpbar(-80,contrast%) 11950 WHEN 7 11960 IF adjust% THEN 11970 IF contrast%<>63 contrast%+=1:ch%=TRUE 11980 ELSE 11990 IF contrast%<>0 contrast%-=1:ch%=TRUE 12000 ENDIF 12010 IF ch% $contad%=STR$contrast%:PROCudpbar(-80,contrast%) 12020 WHEN 11 12030 IF adjust% THEN 12040 IF saturation%<>0 saturation%-=1:ch%=TRUE 12050 ELSE 12060 IF saturation%<>63 saturation%+=1:ch%=TRUE 12070 ENDIF 12080 IF ch% $satad%=STR$saturation%:PROCudpbar(-124,saturation%) 12090 WHEN 12 12100 IF adjust% THEN 12110 IF saturation%<>63 saturation%+=1:ch%=TRUE 12120 ELSE 12130 IF saturation%<>0 saturation%-=1:ch%=TRUE 12140 ENDIF 12150 IF ch% $satad%=STR$saturation%:PROCudpbar(-124,saturation%) 12160 WHEN 4 12170 PROCpalslide(pb%,-36,1) 12180 WHEN 9 12190 PROCpalslide(!pb%,-80,2) 12200 WHEN 14 12210 PROCpalslide(!pb%,-124,3) 12220 WHEN 0 12230 PROCsetpal(0,32,32) 12240 WHEN 16 12250 PROCsetpal(savedbright%,savedcont%,savedsat%) 12260 ENDCASE 12270 12280WHEN w%(15,0) 12290 CASE qflag% OF 12300 WHEN 1 12310 CASE pb%!16 OF 12320 WHEN 0 12330 PROCmenu(8,!pb%-122,pb%!4+84,0) 12340 dragtype%=1 12350 WHEN 2 12360 PROCdeletegrabbed 12370 ENDCASE 12380 WHEN 2 12390 CASE pb%!16 OF 12400 WHEN 0 12410 PROCshutdown(0) 12420 WHEN 2 12430 ENDCASE 12440 WHEN 3 12450 CASE pb%!16 OF 12460 WHEN 0 12470 PROCmenu(7,!pb%-122,pb%!4+84,0) 12480 dragtype%=0 12490 WHEN 2 12500 PROCdeletegrabbed 12510 ENDCASE 12520 ENDCASE 12530 PROCclwin(15) 12540 12550WHEN w%(17,0) 12560 CASE pb%!16 OF 12570 WHEN 0 12580 PROCspeedslide(!pb%) 12590 WHEN 1 12600 IF (pb%!8 AND 1) THEN 12610 IF speed%<>0 THEN 12620 speed%-=1 12630 $speedad%=STR$speed% 12640 PROCspeedbar 12650 ENDIF 12660 ELSE 12670 IF speed%<>99 THEN 12680 speed%+=1 12690 $speedad%=STR$speed% 12700 PROCspeedbar 12710 ENDIF 12720 ENDIF 12730 WHEN 2 12740 IF (pb%!8 AND 1) THEN 12750 IF speed%<>99 THEN 12760 speed%+=1 12770 $speedad%=STR$speed% 12780 PROCspeedbar 12790 ENDIF 12800 ELSE 12810 IF speed%<>0 THEN 12820 speed%-=1 12830 $speedad%=STR$speed% 12840 PROCspeedbar 12850 ENDIF 12860 ENDIF 12870 ENDCASE 12880ENDCASE 12890ENDPROC 12900 12910DEF PROClivemenu 12920mousex%=!pb% 12930mousey%=pb%!4 12940IF bit%=12 THEN 12950 tick12$=">" 12960 cachem$=cache$ 12970ELSE 12980 tick12$="" 12990 cachem$="<" 13000ENDIF 13010IF grabex% shade$="" ELSE shade$="<" 13020IF mono$=">" THEN ms$="<" ELSE ms$="" 13030temp0$="FastGrab|Grab frame|'0156grabsize$'Frame size|'0156livesize$'Live size|" 13040IF board_is_16_bit% THEN 13050 temp1$=ms$+tick12$+"16 bit data|"+ms$+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 13060ELSE 13070 temp1$=tick12$+"12 bit data|"+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 13080ENDIF 13090menu%=FNcmenu(0,temp0$+temp1$,236) 13100mentype%=1 13110ENDPROC 13120 13130DEF PROCgrabmenu 13140mousex%=!pb% 13150mousey%=pb%!4 13160IF grab12% raw$="" ELSE raw$="<" 13170temp0$="FastGrab|@10'Sprite info|@9'Zoom|@7'Save sprite|@1'"+raw$+"ChangeFSI|@14'Credits|" 13180IF board_is_16_bit% THEN 13190 temp1$="@11'"+raw$+"16 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 13200ELSE 13210 temp1$="@11'"+raw$+"12 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 13220ENDIF 13230menu%=FNcmenu(0,temp0$+temp1$,220) 13240mentype%=2 13250ENDPROC 13260 13270DEF PROCpalslide(xpos%,ypos%,dragnum%) 13280!dragging%=dragnum% 13290!mb%=w%(2,0) 13300SYS "Wimp_GetWindowState",,mb% 13310mb%!24=140+mb%!4 13320mb%!28=ypos%+mb%!16 13330mb%!32=392+mb%!4 13340mb%!36=ypos%+20+mb%!16 13350mb%!8=mb%!24 13360mb%!12=mb%!28 13370mb%!16=xpos% 13380mb%!20=mb%!36 13390mb%!4=7 13400SYS "Wimp_DragBox",,mb% 13410ENDPROC 13420 13430DEF PROCudpbar(bary%,value%) 13440IF value%<0 ENDPROC 13450!mb%=w%(2,0) 13460mb%!4=142 13470mb%!8=bary% 13480mb%!12=394 13490mb%!16=bary%+22 13500SYS "Wimp_UpdateWindow",,mb% TO more% 13510x0%=mb%!4-mb%!20 13520y0%=mb%!16-mb%!24 13530WHILE more% 13540 CLG 13550 SYS "Wimp_SetColour",7 13560 RECTANGLE FILL x0%+140,y0%+bary%,value%*4,20 13570 SYS "Wimp_GetRectangle",,mb% TO more% 13580ENDWHILE 13590!mb%=w%(2,0) 13600mb%!4=84 13610mb%!8=bary%-4 13620mb%!12=136 13630mb%!16=bary%+26 13640SYS "Wimp_UpdateWindow",,mb% TO more% 13650x0%=mb%!4-mb%!20 13660y0%=mb%!16-mb%!24 13670WHILE more% 13680 CLG 13690 SYS "Wimp_GetRectangle",,mb% TO more% 13700ENDWHILE 13710CASE bary% OF 13720WHEN -36 13730 PROCbrightness 13740WHEN -80 13750 PROCcontrast 13760WHEN -124 13770 PROCsaturation 13780ENDCASE 13790ENDPROC 13800 13810DEF PROCsetpal(b%,c%,s%) 13820brightness%=b%:contrast%=c%:saturation%=s% 13830$brightad%=STR$(b%) 13840$contad%=STR$(c%) 13850$satad%=STR$(s%) 13860PROCudpbar(-36,b%) 13870PROCudpbar(-80,c%) 13880PROCudpbar(-124,s%) 13890ENDPROC 13900 13910DEF FNcalcbar(xpos%) 13920LOCAL winpos%,value% 13930!mb%=w%(2,0) 13940SYS "Wimp_GetWindowState",,mb% 13950winpos%=xpos%-mb%!4 13960=(winpos%-140)/4 13970 13980DEF PROCdopaldrag 13990SYS "Wimp_GetPointerInfo",,mb% 14000CASE !dragging% OF 14010WHEN 1 14020 newbright%=FNcalcbar(!mb%) 14030 IF brightness%=newbright% ENDPROC 14040 brightness%=newbright% 14050 $brightad%=STR$brightness% 14060 PROCudpbar(-36,brightness%) 14070WHEN 2 14080 newcont%=FNcalcbar(!mb%) 14090 IF contrast%=newcont% ENDPROC 14100 contrast%=newcont% 14110 $contad%=STR$contrast% 14120 PROCudpbar(-80,contrast%) 14130WHEN 3 14140 newsat%=FNcalcbar(!mb%) 14150 IF saturation%=newsat% ENDPROC 14160 saturation%=newsat% 14170 $satad%=STR$saturation% 14180 PROCudpbar(-124,saturation%) 14190ENDCASE 14200ENDPROC 14210 14220DEF PROCspeedslide(xpos%) 14230!dragging%=4 14240!mb%=w%(17,0) 14250SYS "Wimp_GetWindowState",,mb% 14260mb%!24=140+mb%!4 14270mb%!28=-36+mb%!16 14280mb%!32=338+mb%!4 14290mb%!36=-16+mb%!16 14300mb%!8=mb%!24 14310mb%!12=mb%!28 14320mb%!16=xpos% 14330mb%!20=mb%!36 14340mb%!4=7 14350SYS "Wimp_DragBox",,mb% 14360ENDPROC 14370 14380DEF PROCspeedbar 14390IF speed%<0 ENDPROC 14400!mb%=w%(17,0) 14410mb%!4=142 14420mb%!8=-36 14430mb%!12=340 14440mb%!16=-14 14450SYS "Wimp_UpdateWindow",,mb% TO more% 14460x0%=mb%!4-mb%!20 14470y0%=mb%!16-mb%!24 14480WHILE more% 14490 CLG 14500 SYS "Wimp_SetColour",7 14510 RECTANGLE FILL x0%+140,y0%-36,speed%*2,20 14520 SYS "Wimp_GetRectangle",,mb% TO more% 14530ENDWHILE 14540!mb%=w%(17,0) 14550mb%!4=84 14560mb%!8=-40 14570mb%!12=136 14580mb%!16=-10 14590SYS "Wimp_UpdateWindow",,mb% TO more% 14600x0%=mb%!4-mb%!20 14610y0%=mb%!16-mb%!24 14620WHILE more% 14630 CLG 14640 SYS "Wimp_GetRectangle",,mb% TO more% 14650ENDWHILE 14660PROCspeed 14670ENDCASE 14680ENDPROC 14690 14700DEF FNcalcspeed(xpos%) 14710LOCAL winpos%,value% 14720!mb%=w%(17,0) 14730SYS "Wimp_GetWindowState",,mb% 14740winpos%=xpos%-mb%!4 14750=(winpos%-140)/2 14760 14770DEF PROCdospeeddrag 14780SYS "Wimp_GetPointerInfo",,mb% 14790newspeed%=FNcalcspeed(!mb%) 14800IF speed%=newspeed% ENDPROC 14810speed%=newspeed% 14820$speedad%=STR$speed% 14830PROCspeedbar 14840ENDPROC 14850 14860DEF PROCspeed 14870!speedval=99-speed% 14880ENDPROC 14890 14900DEF PROCcontrast 14910?IICblock%=2 14920IICblock%?1=contrast% 14930SYS &240,136,IICblock%,2 14940ENDPROC 14950 14960DEF PROCsaturation 14970?IICblock%=1 14980IICblock%?1=saturation% 14990SYS &240,136,IICblock%,2 15000ENDPROC 15010 15020DEF PROCbrightness 15030?IICblock%=0 15040IICblock%?1=brightness% 15050SYS &240,136,IICblock%,2 15060ENDPROC 15070 15080DEF PROCchkbnds(address%) 15090IF LEN$address%=0 $address%="0" 15100IF VAL$address%>63 $address%="63" 15110ENDPROC 15120 15130DEF PROCdragend 15140LOCAL dx%,dy%,dw%,di% 15150CASE !dragging% OF 15160WHEN 1,2,3,4 15170 !dragging%=0 15180 ENDPROC 15190ENDCASE 15200CASE dragtype% OF 15210WHEN 0,1 15220 SYS "Wimp_GetPointerInfo",,mb% 15230 dx%=!mb% 15240 dy%=mb%!4 15250 dw%=mb%!12 15260 di%=mb%!16 15270 CASE dragtype% OF 15280 WHEN 0 15290 fnamelen%=LEN($outsprad%) 15300 filesize%=spritesize%-4 15310 filetype%=&FF9 15320 $(mb%+44)=FNzt(outsprad%)+CHR$0+CHR$0+CHR$0+CHR$0 15330 WHEN 1 15340 fnamelen%=LEN($outrawad%) 15350 filesize%=rawsize% 15360 filetype%=&FFD 15370 $(mb%+44)=FNzt(outrawad%)+CHR$0+CHR$0+CHR$0+CHR$0 15380 ENDCASE 15390 PROCround(fnamelen%,4) 15400 fnamelen%+=4 15410 dummy%=filesize% 15420 PROCround(dummy%,4) 15430 !mb%=44+fnamelen% 15440 mb%!12=0 15450 mb%!16=1 15460 mb%!20=dw% 15470 mb%!24=di% 15480 mb%!28=dx% 15490 mb%!32=dy% 15500 mb%!36=dummy%+1024 15510 mb%!40=filetype% 15520 SYS "Wimp_SendMessage",17,mb%,dw%,di% 15530 myref%=mb%!8 15540 dragtype%=-1 15550ENDCASE 15560ENDPROC 15570 15580DEF PROCdatasaveack 15590IF pb%!12=myref% THEN 15600 save$=FNzt(pb%+44) 15610 CASE filetype% OF 15620 WHEN &FF9 15630 SYS "OS_SpriteOp",&10C,grabarea%,save$ 15640 IF pb%!36<>-1 THEN 15650 IF cfsid% suffix$=" CFSI" ELSE suffix$=" 8 bit" 15660 saved8%=TRUE 15670 $grabwtitlead%=save$+suffix$ 15680 PROCupdatetitle 15690 ENDIF 15700 WHEN &FFD 15710 rawout%=OPENOUT(save$) 15720 IF slave% THEN 15730 rawin%=OPENIN("<FastGrab$Dir>.Resources.TwelveBit") 15740 IF rawin%=0 ERROR 214,"Cache file cannot be found" 15750 SYS "OS_GBPB",4,rawin%,livearea%+100,100000 15760 SYS "OS_GBPB",2,rawout%,livearea%+100,100000 15770 SYS "OS_GBPB",4,rawin%,livearea%+100,96628 15780 SYS "OS_GBPB",2,rawout%,livearea%+100,96628 15790 CLOSE#rawin% 15800 ELSE 15810 SYS "OS_GBPB",2,rawout%,rawarea%,rawsize% 15820 ENDIF 15830 CLOSE#rawout% 15840 IF pb%!36<>-1 THEN 15850 saved12%=TRUE 15860 IF board_is_16_bit% $grabwtitlead%=save$+" 16 bit" ELSE $grabwtitlead%=save$+" 12 bit" 15870 PROCupdatetitle 15880 ENDIF 15890 ENDCASE 15900 pb%!12=pb%!8 15910 pb%!16=3 15920 SYS "Wimp_SendMessage",18,pb%,pb%!4 15930 SYS "Wimp_CreateMenu",,-1 15940ENDIF 15950ENDPROC 15960 15970DEF FNzt(address%) 15980LOCAL pos% 15990pos%=0 16000string$="" 16010REPEAT 16020 string$+=CHR$address%?pos% 16030 pos%+=1 16040UNTIL address%?pos%<32 16050=string$ 16060 16070DEF PROCputword(handle%,word%) 16080BPUT#handle%,word% AND &FF 16090BPUT#handle%,(word% AND &FF00)>>8 16100BPUT#handle%,(word% AND &FF0000)>>16 16110BPUT#handle%,(word% AND &FF000000)>>24 16120ENDPROC 16130 16140DEF FNgetword(handle%) 16150byte0%=BGET#handle% 16160byte1%=BGET#handle% 16170byte2%=BGET#handle% 16180byte3%=BGET#handle% 16190=(byte3%<<24) OR (byte2%<<16) OR (byte1%<<8) OR byte0% 16200 16210DEF PROChandlekey 16220mine%=FALSE 16230CASE !pb% OF 16240 16250WHEN w%(1,0) 16260 CASE pb%!24 OF 16270 WHEN 13 16280 mine%=TRUE 16290 CASE pb%!4 OF 16300 WHEN 0,1,2,3 16310 SYS "Wimp_SetCaretPosition",w%(1,0),pb%!4+1,,,-1,LEN($FNiconad(1,pb%!4+1)) 16320 WHEN 4 16330 SYS "Wimp_SetCaretPosition",w%(1,0),22,,,-1,LEN($sharpenad%) 16340 WHEN 22 16350 SYS "Wimp_SetCaretPosition",w%(1,0),30,,,-1,LEN($blackad%) 16360 WHEN 30 16370 SYS "Wimp_SetCaretPosition",w%(1,0),31,,,-1,LEN($gammaad%) 16380 WHEN 31 16390 SYS "Wimp_CreateMenu",,-1 16400 PROCgocfsi 16410 ENDPROC 16420 ENDCASE 16430 WHEN &18E 16440 mine%=TRUE 16450 CASE pb%!4 OF 16460 WHEN 0,1,2,3 16470 SYS "Wimp_SetCaretPosition",w%(1,0),pb%!4+1,,,-1,LEN($FNiconad(1,pb%!4+1)) 16480 WHEN 4 16490 SYS "Wimp_SetCaretPosition",w%(1,0),22,,,-1,LEN($sharpenad%) 16500 WHEN 22 16510 SYS "Wimp_SetCaretPosition",w%(1,0),30,,,-1,LEN$(blackad%) 16520 WHEN 30 16530 SYS "Wimp_SetCaretPosition",w%(1,0),31,,,-1,LEN$(gammaad%) 16540 WHEN 31 16550 SYS "Wimp_SetCaretPosition",w%(1,0),0,,,-1,LEN$(modead%) 16560 ENDCASE 16570 WHEN &18F 16580 mine%=TRUE 16590 CASE pb%!4 OF 16600 WHEN 0 16610 SYS "Wimp_SetCaretPosition",w%(1,0),31,,,-1,LEN($gammaad%) 16620 WHEN 1 16630 SYS "Wimp_SetCaretPosition",w%(1,0),0,,,-1,LEN$(modead%) 16640 WHEN 2,3,4 16650 SYS "Wimp_SetCaretPosition",w%(1,0),pb%!4-1,,,-1,LEN($FNiconad(1,pb%!4-1)) 16660 WHEN 22 16670 SYS "Wimp_SetCaretPosition",w%(1,0),4,,,-1,LEN($FNiconad(1,4)) 16680 WHEN 30 16690 SYS "Wimp_SetCaretPosition",w%(1,0),22,,,-1,LEN($sharpenad%) 16700 WHEN 31 16710 SYS "Wimp_SetCaretPosition",w%(1,0),30,,,-1,LEN($blackad%) 16720 ENDCASE 16730 ENDCASE 16740 16750WHEN w%(9,0) 16760 CASE pb%!24 OF 16770 WHEN &18E,&18F 16780 mine%=TRUE 16790 CASE pb%!4 OF 16800 WHEN 0 16810 SYS "Wimp_SetCaretPosition",w%(9,0),1,,,-1,LEN($mag2ad%) 16820 WHEN 1 16830 SYS "Wimp_SetCaretPosition",w%(9,0),0,,,-1,LEN($mag1ad%) 16840 ENDCASE 16850 WHEN 13 16860 mine%=TRUE 16870 CASE pb%!4 OF 16880 WHEN 0 16890 SYS "Wimp_SetCaretPosition",w%(9,0),1,,,-1,LEN($mag2ad%) 16900 WHEN 1 16910 SYS "Wimp_SetCaretPosition",w%(9,0),0,,,-1,LEN($mag1ad%) 16920 ENDCASE 16930 ENDCASE 16940 IF mine% PROCmagstring(0,0) 16950 16960WHEN w%(7,0) 16970 CASE pb%!24 OF 16980 WHEN 13 16990 mine%=TRUE 17000 PROCsavesprite 17010 SYS "Wimp_CreateMenu",,-1 17020 ENDCASE 17030 17040WHEN w%(8,0) 17050 CASE pb%!24 OF 17060 WHEN 13 17070 mine%=TRUE 17080 PROCsaveraw 17090 SYS "Wimp_CreateMenu",,-1 17100 ENDCASE 17110 17120WHEN w%(2,0) 17130 CASE pb%!24 OF 17140 WHEN 13 17150 mine%=TRUE 17160 CASE pb%!4 OF 17170 WHEN 3 17180 SYS "Wimp_SetCaretPosition",w%(2,0),8,,,-1,LEN($contad%) 17190 PROCchkbnds(brightad%) 17200 brightness%=VAL$brightad% 17210 PROCudpbar(-36,brightness%) 17220 WHEN 8 17230 SYS "Wimp_SetCaretPosition",w%(2,0),13,,,-1,LEN($satad%) 17240 PROCchkbnds(contad%) 17250 contrast%=VAL$contad% 17260 PROCudpbar(-80,contrast%) 17270 WHEN 13 17280 SYS "Wimp_CreateMenu",,-1 17290 PROCchkbnds(satad%) 17300 saturation%=VAL$satad% 17310 ENDCASE 17320 WHEN &18E 17330 mine%=TRUE 17340 CASE pb%!4 OF 17350 WHEN 3 17360 SYS "Wimp_SetCaretPosition",w%(2,0),8,,,-1,LEN($contad%) 17370 PROCchkbnds(brightad%) 17380 brightness%=VAL$brightad% 17390 PROCudpbar(-36,brightness%) 17400 WHEN 8 17410 SYS "Wimp_SetCaretPosition",w%(2,0),13,,,-1,LEN($satad%) 17420 PROCchkbnds(contad%) 17430 contrast%=VAL$contad% 17440 PROCudpbar(-80,contrast%) 17450 WHEN 13 17460 SYS "Wimp_SetCaretPosition",w%(2,0),3,,,-1,LEN($brightad%) 17470 PROCchkbnds(satad%) 17480 saturation%=VAL$satad% 17490 PROCudpbar(-124,saturation%) 17500 ENDCASE 17510 WHEN &18F 17520 mine%=TRUE 17530 CASE pb%!4 OF 17540 WHEN 3 17550 SYS "Wimp_SetCaretPosition",w%(2,0),13,,,-1,LEN($satad%) 17560 PROCchkbnds(brightad%) 17570 brightness%=VAL$brightad% 17580 PROCudpbar(-36,brightness%) 17590 WHEN 8 17600 SYS "Wimp_SetCaretPosition",w%(2,0),3,,,-1,LEN($brightad%) 17610 PROCchkbnds(contad%) 17620 contrast%=VAL$contad% 17630 PROCudpbar(-80,contrast%) 17640 WHEN 13 17650 SYS "Wimp_SetCaretPosition",w%(2,0),8,,,-1,LEN($contad%) 17660 PROCchkbnds(satad%) 17670 saturation%=VAL$satad% 17680 PROCudpbar(-124,saturation%) 17690 ENDCASE 17700 ENDCASE 17710 17720WHEN w%(17,0) 17730 CASE pb%!24 OF 17740 WHEN 13 17750 mine%=TRUE 17760 speed%=VAL$speedad% 17770 PROCspeed 17780 SYS "Wimp_CreateMenu",,-1 17790 ENDCASE 17800 OTHERWISE 17810 SYS "Wimp_ProcessKey",pb%!24 17820ENDCASE 17830 17840IF NOT mine% SYS "Wimp_ProcessKey",pb%!24 17850 17860ENDPROC 17870 17880DEF PROCmessage 17890CASE pb%!16 OF 17900WHEN 0 17910 PROCshutdown(0) 17920WHEN 1 17930 PROCdatasave 17940WHEN 2 17950 PROCdatasaveack 17960WHEN 3 17970 PROCfilecoming 17980WHEN 8 17990 pb%!12=pb%!8 18000 SYS "Wimp_SendMessage",19,pb% 18010 quitting%=TRUE 18020 quithand%=pb%!4 18030 PROCshutdown(-1) 18040WHEN 9 18050 PROCmodechanged 18060 PROCupdatesprite 18070WHEN &502 18080 PROCsendhelp 18090WHEN &400C0 18100 PROCmenuwarning 18110WHEN &400C1 18120 PROCmodechanged 18130ENDCASE 18140ENDPROC 18150 18160DEF PROCfilecoming 18170IF pb%!20=-2 THEN 18180 IF pb%!40<>&FFD ERROR 42,"FastGrab can only process files of type Data" 18190 lh%=OPENIN(FNzt(pb%+44)+CHR$13) 18200 IF lh%=0 ERROR 214,"File not found" 18210 IF FNgetword(lh%)<>&6372654D CLOSE#lh%:ERROR 42,"Fastgrab can only process video image files from the Hawk V9 and Hawk V9 Mk II" 18220 CASE FNgetword(lh%) OF 18230 WHEN &74666F53 18240 in_file_bits%=12 18250 WHEN &31666F53 18260 in_file_bits%=16 18270 OTHERWISE 18280 CLOSE#lh% 18290 ERROR 42,"FastGrab can only process video image files from the Hawk V9 and Hawk V9 Mk II" 18300 ENDCASE 18310 SYS "Wimp_SendMessage",19,pb%,pb%!4 18320 SYS "Wimp_SlotSize",originalslot%,-1 18330 nextlocation%=HIMEM 18340 spritesize%=0 18350 inx%=FNgetword(lh%) 18360 gpx%=inx% 18370 iny%=FNgetword(lh%) 18380 gpy%=iny% 18390 CASE in_file_bits% OF 18400 WHEN 12 18410 rawsize%=inx%*iny%*3/2+20 18420 $grabwtitlead%=$(pb%+44)+" 12 bit" 18430 WHEN 16 18440 rawsize%=inx%*iny%*2+20 18450 $grabwtitlead%=$(pb%+44)+" 16 bit" 18460 ENDCASE 18470 PROCupdatetitle 18480 grab12%=TRUE 18490 grabex%=TRUE 18500 PROCgrabmemory(20,0) 18510 SYS "OS_GBPB",3,lh%,rawarea%,rawsize%,0 18520 CLOSE#lh% 18530 IF scrappy% THEN 18540 scrappy%=FALSE 18550 *Remove <Wimp$Scrap> 18560 ENDIF 18570 PROCsetupraw(rawsize%,rawarea%!8,rawarea%!12,rawarea%?17,rawarea%?18,rawarea%?19) 18580 done%=FNChangeFSI("ChangeFSI null null 15 1:1",-1,-1,grabarea%,0,0,ram%,0,rawarea%) 18590 cfsid%=TRUE 18600 grabarea%=ram% 18610 sprex%=TRUE 18620 saved8%=TRUE 18630 saved12%=TRUE 18640 PROCsetupsprite 18650 IF NOT w%(5,2) THEN 18660 PROCcwin(5) 18670 !grabwb=w%(5,0) 18680 ENDIF 18690 IF NOT w%(6,2) PROCcwin(6) 18700 grabwb!4=grabarea% 18710 grabwb!8=grabarea%+16 18720 SYS "OS_SpriteOp",&228,grabarea%,grabarea%+16 TO ,,,grabwx%,grabwy%,spmask%,spmd% 18730 SYS "OS_ReadModeVariable",-1,4 TO ,,xshift% 18740 SYS "OS_ReadModeVariable",-1,5 TO ,,yshift% 18750 grabwx%=grabwx%<<xshift% 18760 grabwy%=grabwy%<<yshift% 18770 PROCadjustgrab 18780 PROCmagstring(0,0) 18790ENDIF 18800ENDPROC 18810 18820DEF PROCdatasave 18830IF pb%!20=-2 AND pb%!24=iconbar% THEN 18840 !pb%=60 18850 pb%!12=pb%!8 18860 pb%!16=2 18870 pb%!36=-1 18880 $(pb%+44)="<Wimp$Scrap>" 18890 pb%?56=0 18900 SYS "Wimp_SendMessage",17,pb%,pb%!4 18910 scrappy%=TRUE 18920ENDIF 18930ENDPROC 18940 18950DEF PROCgocfsi 18960LOCAL fsi$ 18970IF $modead%="" mode$="15" 18980mode$=$modead% 18990CASE VAL(mode$) OF 19000WHEN 2,4,5,10 19010 mode$="15" 19020OTHERWISE 19030 SYS "OS_ReadModeVariable",VALmode$,0 TO ,,modeflags%;armflags% 19040 IF (armflags% AND 1<<29) THEN 19050 mode$="15 " 19060 ELSE 19070 IF (modeflags% AND 1) mode$="15" 19080 SYS "OS_ReadModeVariable",VALmode$,3 TO ,,ncolour% 19090 IF ncolour%<15 AND outmode$="T" outmode$=" " 19100 ENDIF 19110ENDCASE 19120$modead%=mode$ 19130IF VAL$x1ad%<1 $x1ad%="1" 19140IF VAL$x2ad%<1 $x2ad%="1" 19150IF VAL$y1ad%<1 $y1ad%="1" 19160IF VAL$y2ad%<1 $y2ad%="1" 19170IF FNselected(5) THEN 19180 scale$=" = " 19190ELSE 19200 scale$=" "+$x1ad%+":"+$x2ad%+" "+$y1ad%+":"+$y2ad% 19210ENDIF 19220option$=" " 19230IF FNselected(11) option$+="-range " 19240IF FNselected(12) option$+="-equal " 19250IF FNselected(14) option$+="-invert " 19260IF FNselected(15) option$+="-sharpen"+$(sharpenad%) 19270IF FNselected(23) option$+="-hflip " 19280IF FNselected(24) option$+="-vflip " 19290IF FNselected(16) option$+="-noscale " 19300IF FNselected(26) option$+="-nodither " 19310IF FNselected(27) option$+="-brighten " 19320IF FNselected(28) option$+="-black"+$(blackad%) 19330IF $gammaad%="" $gammad%="2.2" 19340IF FNselected(29) option$+="-gamma"+$(gammaad%) 19350fsi$="ChangeFSI null Piccy1 "+mode$+outmode$+scale$+option$ 19360IF FNselected(13) SYS "Wimp_SetMode",0 19370SYS "Wimp_SlotSize",precfsislot%,-1 19380IF board_is_16_bit% THEN in_file_bits%=16 ELSE in_file_bits%=12 19390done%=FNChangeFSI(fsi$,-1,-1,grabarea%,0,0,ram%,0,rawarea%) 19400cfsid%=TRUE 19410grabarea%=ram% 19420IF done%=100 ERROR 42,"Histogram equalization of image not possible" 19430sprex%=TRUE 19440saved8%=FALSE 19450$grabwtitlead%="<untitled> * CFSI" 19460IF MODE=oldmode% THEN 19470PROCmodechanged 19480PROCupdatetitle 19490ELSE 19500SYS "Wimp_SetMode",oldmode% 19510ENDIF 19520PROCsetupsprite 19530grabwb!4=grabarea% 19540grabwb!8=grabarea%+16 19550SYS "OS_SpriteOp",&228,grabarea%,grabarea%+16 TO ,,,grabwx%,grabwy%,spmask%,spmd% 19560SYS "OS_ReadModeVariable",-1,4 TO ,,xshift% 19570SYS "OS_ReadModeVariable",-1,5 TO ,,yshift% 19580grabwx%=grabwx%<<xshift% 19590grabwy%=grabwy%<<yshift% 19600PROCadjustgrab 19610PROCmagstring(0,0) 19620ENDPROC 19630 19640DEF PROCsetupsprite 19650LOCAL sx%,sy%,spmd% 19660SYS "OS_SpriteOp",&228,grabarea%,grabarea%+16 TO ,,,sx%,sy%,spmask%,spmd% 19670$grabnamead%=oname$ 19680$grabmodead%=STR$spmd% 19690CASE spmask% OF 19700WHEN 0:$grabmaskad%="No" 19710WHEN 1:$grabmaskad%="Yes" 19720ENDCASE 19730$grabwidtad%=STR$sx% 19740sptr%=grabarea%+16 19750IF sptr%!32=44 THEN 19760$grabpalad%="No" 19770ELSE 19780$grabpalad%="Yes" 19790ENDIF 19800$grabbytead%=STR$(!sptr%) 19810$grabheigad%=STR$sy% 19820ENDPROC 19830DEF PROCsetupraw(size%,xsize%,ysize%,b%,c%,s%) 19840$rawbytesad%=STR$size% 19850$rawwidthad%=STR$xsize% : 19860$rawheightad%=STR$ysize% 19870$rawbrightad%=STR$b% 19880$rawcontad%=STR$c% 19890$rawsatad%=STR$s% 19900ENDPROC 19910 19920DEF FNselected(icon%) 19930IF w%(1,2) THEN 19940!mb%=w%(1,0) 19950mb%!4=icon% 19960SYS "Wimp_GetIconState",,mb% 19970IF mb%!24 AND 1<<21 THEN =1 ELSE =0 19980ELSE 19990IF !(w%(1,1)+108+(32*icon%)) AND (1<<21) THEN 20000=1 20010ELSE 20020=0 20030ENDIF 20040ENDIF 20050 20060DEF PROCiconset(window%,icon%,clear%,eor%) 20070IF w%(window%,2) THEN 20080!mb%=w%(window%,0) 20090mb%!4=icon% 20100mb%!8=eor% 20110mb%!12=clear% 20120SYS "Wimp_SetIconState",,mb% 20130ELSE 20140w%(window%,1)!(108+32*icon%)=(w%(window%,1)!(108+32*icon%) AND NOT clear%) EOR eor% 20150ENDIF 20160ENDPROC 20170 20180DEF PROCadjustlive 20190PROCcalclive 20200!mb%=w%(3,0) 20210SYS "Wimp_GetWindowState",,mb% 20220mb%!8=mb%!16-livey% 20230mb%!12=mb%!4+livex% 20240IF mb%!4<0 mb%!4=0 20250IF mb%!8>rightscr% mb%!8=rightscr% 20260SYS "Wimp_OpenWindow",,mb% 20270IF ltool$=">" THEN 20280!mb%=w%(4,0) 20290mb%!12=mb%!4-4 20300mb%!4-=88 20310SYS "Wimp_OpenWindow",,mb% 20320ENDIF 20330ENDPROC 20340 20350DEF PROCcalclive 20360lpx%=512/(2^livesize%) 20370!livepagestep=8*(2^livesize%) 20380!livepixelstep=2^(livesize%+2) 20390lpy%=lpx%/2 20400livearea%!12=lpx%*lpy%+60 20410livearea%!16=livearea%!12-16 20420livearea%!32=(lpx%/4)-1 20430livearea%!36=lpy%-1 20440SYS "OS_ReadModeVariable",15,4 TO ,,xshift% 20450SYS "OS_ReadModeVariable",15,5 TO ,,yshift% 20460livex%=lpx%<<xshift% 20470livey%=lpy%<<yshift% 20480!livewb=w%(3,0) 20490livewb!4=livearea% 20500livewb!8=livearea%+16 20510livewb!12=0 20520livewb!16=-livey% 20530!livexsize=livex% 20540!liveysize=-livey% 20550!mb%=0 20560mb%!4=-livey% 20570mb%!8=livex% 20580mb%!12=0 20590SYS "Wimp_SetExtent",w%(3,0),mb% 20600w%(3,1)!44=0 20610w%(3,1)!48=-livey% 20620w%(3,1)!52=livex% 20630w%(3,1)!56=0 20640ENDPROC 20650 20660DEF PROCadjustgrab 20670LOCAL sheight%,swidth%,smode%,sch%,scw% 20680SYS "OS_SpriteOp",&228,grabarea%,grabarea%+16 TO ,,,swidth%,sheight%,,smode% 20690SYS "OS_ReadModeVariable",smode%,4 TO ,,xshift% 20700SYS "OS_ReadModeVariable",smode%,5 TO ,,yshift% 20710scw%=(swidth%<<xshift%)*VAL($mag1ad%)/VAL($mag2ad%) 20720sch%=(sheight%<<yshift%)*VAL($mag1ad%)/VAL($mag2ad%) 20730scw%=(scw% DIV 4)*4 20740sch%=(sch% DIV 4)*4 20750grabwb!12=0 20760grabwb!16=-sch% 20770IF scw%<=108 OR sch%<=108 THEN 20780 IF w%(5,1)?39=&FF THEN 20790 PROCdwin(5) 20800 w%(5,1)?39=0 20810 PROCcwin(5) 20820 SYS "Wimp_OpenWindow",,w%(5,1) 20830 ENDIF 20840SYS "Wimp_ForceRedraw",w%(5,0),0,-256,128,0 20850ELSE 20860 IF w%(5,1)?39=0 THEN 20870 PROCdwin(5) 20880 w%(5,1)?39=&FF 20890 PROCcwin(5) 20900 SYS "Wimp_OpenWindow",,w%(5,1) 20910 ENDIF 20920ENDIF 20930IF w%(5,2) THEN 20940 !mb%=0 20950 mb%!4=-sch% 20960 mb%!8=scw% 20970 mb%!12=0 20980 SYS "Wimp_SetExtent",w%(5,0),mb% 20990ELSE 21000 w%(5,1)!44=!mb% 21010 w%(5,1)!48=mb%!4 21020 w%(5,1)!52=mb%!8 21030 w%(5,1)!56=mb%!12 21040ENDIF 21050SYS "Wimp_GetWindowState",,w%(5,1) 21060SYS "Wimp_ForceRedraw",w%(5,0),0,-sch%,scw%,0 21070w%(5,1)!8=w%(5,1)!16-sch% 21080w%(5,1)!12=w%(5,1)!4+scw% 21090SYS "Wimp_OpenWindow",,w%(5,1) 21100IF gtool$=">" THEN 21110 !mb%=w%(6,0) 21120 mb%!4=w%(5,1)!4-88 21130 mb%!8=w%(5,1)!8 21140 mb%!12=w%(5,1)!4-4 21150 mb%!16=w%(5,1)!16 21160 mb%!28=w%(5,1)!28 21170 SYS "Wimp_OpenWindow",,mb% 21180ENDIF 21190PROCpalette_for_sprite(grabarea%,grabarea%+16,grabpal%) 21200ENDPROC 21210 21220DEF PROCmagstring(one%,two%) 21230SYS "Wimp_ReadPixTrans",&200,grabarea%,grabarea%+16,,,,magt%+16,mb% 21240IF one%<>0 $mag1ad%=STR$(VAL($mag1ad%)+one%) 21250IF two%<>0 $mag2ad%=STR$(VAL($mag2ad%)+two%) 21260IF VAL($mag1ad%)<1 $mag1ad%="1":ENDPROC 21270IF VAL($mag1ad%)>999 $mag1ad%="999":ENDPROC 21280IF VAL($mag2ad%)<1 $mag2ad%="1":ENDPROC 21290IF VAL($mag2ad%)>999 $mag2ad%="999":ENDPROC 21300IF w%(9,2) SYS "Wimp_ForceRedraw",w%(9,0),72,0,200,290 21310!magt%=magt%!16*VAL($mag1ad%) 21320magt%!4=magt%!20*VAL($mag1ad%) 21330magt%!8=magt%!24*VAL($mag2ad%) 21340magt%!12=magt%!28*VAL($mag2ad%) 21350PROCadjustgrab 21360ENDPROC 21370DEF PROCgrab 21380PROCdeletegrabbed 21390saved12%=FALSE 21400saved8%=FALSE 21410$grabwtitlead%="<untitled> * 8 bit" 21420PROCupdatetitle 21430gpx%=512/(2^grabsize%) 21440!pagestep=8*(2^grabsize%) 21450!pixelstep=2^(grabsize%+2) 21460gpy%=gpx%/2 21470spritesize%=gpx%*gpy%+56 21480IF board_is_16_bit% rawsize%=262164 ELSE rawsize%=199628 21490nextlocation%=HIMEM 21500SYS "OS_ReadModeVariable",VAL($modeb%),4 TO ,,xshift% 21510SYS "OS_ReadModeVariable",VAL($modeb%),5 TO ,,yshift% 21520grabwx%=gpx%<<xshift% 21530grabwy%=gpy%<<yshift% 21540IF NOT w%(5,2) THEN 21550 PROCcwin(5) 21560 !grabwb=w%(5,0) 21570ENDIF 21580IF NOT w%(6,2) PROCcwin(6) 21590IF mono$=">" THEN 21600 PROCgrabmemory(8,-1) 21610 grabwb!4=grabarea% 21620 grabwb!8=grabarea%+16 21630 PROCreadV98 21640 grab12%=FALSE 21650 PROCiconset(6,0,1<<22,1<<22) 21660 PROCiconset(6,3,1<<22,1<<22) 21670ELSE 21680 IF bit%=12 THEN 21690 PROCgrabmemory(20,-1) 21700 PROCreadV912 21710 CALLset_8bit 21720 !grabarea%=spritesize% 21730 grabarea%!4=1 21740 grabarea%!8=16 21750 grabarea%!12=spritesize% 21760 grabwb!4=grabarea% 21770 grabwb!8=grabarea%+16 21780 PROCreadV98 21790 grab12%=TRUE 21800 PROCiconset(6,0,1<<22,0) 21810 PROCiconset(6,3,1<<22,0) 21820 PROCsetupraw(rawsize%,gpx%,gpy%,brightness%,contrast%,saturation%) 21830 ELSE 21840 PROCgrabmemory(8,-1) 21850 grabwb!4=grabarea% 21860 grabwb!8=grabarea%+16 21870 PROCreadV98 21880 grab12%=FALSE 21890 PROCiconset(6,0,1<<22,1<<22) 21900 PROCiconset(6,3,1<<22,1<<22) 21910 ENDIF 21920ENDIF 21930LOCAL ERROR 21940ON ERROR ON ERROR OFF:$modeb%="15":grabarea%!56=15 21950SYS "Wimp_ReadPixTrans",&200,grabwb!4,grabwb!8,,,,magt%,mb% 21960RESTORE ERROR 21970PROCiconset(4,1,1<<22,0) 21980$grabnamead%="grabbed" 21990$grabmodead%=$modeb% 22000$grabmaskad%="No" 22010$grabwidtad%=STR$gpx% 22020IF mono$<>">" THEN $grabpalad%="No" ELSE $grabpalad%="Yes" 22030SYS "OS_SpriteOp",&218,grabarea%,grabarea%+16 TO ,,sptr% 22040$grabbytead%=STR$(!sptr%) 22050$grabheigad%=STR$gpy% 22060$grabwidtad%=STR$gpx% 22070grabwb!20=magt% 22080grabex%=TRUE 22090grabch%=TRUE 22100grabch%=FALSE 22110PROCadjustgrab 22120PROCmagstring(0,0) 22130ENDPROC 22140 22150DEF PROCgrabmemory(arg%,arg1%) 22160SYS "Wimp_SlotSize",-1,-1 TO currentslot%,,freeslot% 22170IF freeslot%<=spritesize% ERROR 42,"Cannot claim enough memory to grab image" 22180CASE arg% OF 22190WHEN 8 22200 SYS "Wimp_SlotSize",currentslot%+spritesize%,-1 22210 grabarea%=nextlocation% 22220 nextlocation%+=spritesize% 22230 !grabarea%=spritesize% 22240 grabarea%!4=1 22250 grabarea%!8=16 22260 grabarea%!12=spritesize% 22270 grabwb!4=grabarea% 22280 grabwb!8=grabarea%+16 22290WHEN 20 22300 IF freeslot%<=spritesize%+rawsize% OR cache$=">" AND arg1% THEN 22310 SYS "Wimp_SlotSize",currentslot%+spritesize%,-1 22320 precfsislot%=currentslot% 22330 grabarea%=nextlocation% 22340 nextlocation%+=spritesize% 22350 slave%=TRUE 22360 twelvehandle%=OPENOUT("<FastGrab$Dir>.Resources.TwelveBit") 22370 PROCputword(twelvehandle%,&6372654D) 22380 PROCputword(twelvehandle%,&74666F53) 22390 PROCputword(twelvehandle%,512) 22400 PROCputword(twelvehandle%,256) 22410 BPUT#twelvehandle%,0 22420 rawarea%=0 22430 ELSE 22440 slave%=FALSE 22450 SYS "Wimp_SlotSize",currentslot%+rawsize%+spritesize%,-1 22460 precfsislot%=currentslot%+rawsize% 22470 rawarea%=nextlocation% 22480 grabarea%=nextlocation%+rawsize% 22490 nextlocation%+=rawsize%+spritesize% 22500 ENDIF 22510ENDCASE 22520ENDPROC 22530 22540DEF PROCreadV98 22550grabarea%!16=spritesize%+44 22560$(grabarea%+20)="grabbed"+CHR$0+CHR$0+CHR$0+CHR$0+CHR$0 22570grabarea%!32=(gpx%/4)-1 22580grabarea%!36=gpy%-1 22590grabarea%!40=&00 22600grabarea%!44=&1F 22610grabarea%!48=&2C 22620grabarea%!52=&2C 22630grabarea%!56=VAL($modeb%) 22640IF mono$=">" THEN 22650 PROCadd_palette_to_sprite(grabarea%,grabarea%+16,grabpal%) 22660 F%=grabarea%+60+2048 22670 CALL VRAM_Grab 22680ELSE 22690 F%=grabarea%+60 22700 CALL set_8bit 22710 CALL VRAM_Grab 22720ENDIF 22730PROCmodechanged 22740ENDPROC 22750 22760DEF PROCreadV912 22770SYS &406C0 22780 22790IF board_is_16_bit% THEN 22800 CALL Refresh_Frame 22810 SYS "WVCGrab_LCA",2 22820 CALL Refresh_Frame 22830ENDIF 22840 22850CALL set_12bit 22860 22870IF slave% THEN 22880 SYS "WVCGrab_Refresh",1 22890 BPUT#twelvehandle%,brightness% 22900 BPUT#twelvehandle%,contrast% 22910 BPUT#twelvehandle%,saturation% 22920 A%=mb% 22930 FOR B%=0 TO 255 22940 IF board_is_16_bit% THEN 22950 CALL read16bit 22960 SYS "OS_GBPB",2,twelvehandle%,mb%,1024 22970 ELSE 22980 CALL packline 22990 SYS "OS_GBPB",2,twelvehandle%,mb%,768 23000 ENDIF 23010 SYS &406C4,(B%/255)*100 23020 NEXT 23030 CLOSE#twelvehandle% 23040 SYS "WVCGrab_Refresh",0 23050ELSE 23060 FOR B%=0 TO 255 23070 SYS &406C4,(B%/255)*100 23080 IF board_is_16_bit% THEN 23090 A%=rawarea%+20+(B%*1024) 23100 CALL read16bit 23110 ELSE 23120 A%=rawarea%+20+(B%*768) 23130 CALL packline 23140 ENDIF 23150 NEXT 23160ENDIF 23170 23180PROCchange_LCA(dithered%) 23190 23200SYS &406C1 23210IF rawarea% THEN 23220 !rawarea%=&6372654D : REM "Merc" 23230 IF board_is_16_bit% THEN 23240 rawarea%!4=&31666F53 : REM "Sof1" 23250 ELSE 23260 rawarea%!4=&74666F53 : REM "Soft" 23270 ENDIF 23280 rawarea%!8=gpx% 23290 rawarea%!12=gpy% 23300 rawarea%?16=0 23310 rawarea%?17=brightness% 23320 rawarea%?18=contrast% 23330 rawarea%?19=saturation% 23340ENDIF 23350 23360CALL set_8bit 23370 23380ENDPROC 23390 23400DEF PROCshowgrab 23410IF NOT w%(5,2) PROCcwin(5):!grabwb=w%(5,0) 23420IF NOT w%(6,2) AND gtool$=">" PROCcwin(6) 23430!mb%=w%(5,0) 23440IF NOT grabch% THEN 23450 SYS "Wimp_GetWindowState",,mb% 23460 mb%!28=-1 23470 SYS "Wimp_OpenWindow",,mb% 23480ELSE 23490 mb%!4=rightscr%/2-grabwx%/2 23500 mb%!8=topscr%/2-grabwy%/2 23510 mb%!12=rightscr%/2+grabwx%/2 23520 mb%!16=topscr%/2+grabwy%/2 23530 IF mb%!8<0 mb%!8=84 23540 mb%!20=0 23550 mb%!24=0 23560 mb%!28=-1 23570 SYS "Wimp_OpenWindow",,mb% 23580 SYS "Wimp_ForceRedraw",w%(5,0),0,-grabwy%,grabwx%,0 23590ENDIF 23600IF gtool$=">" THEN 23610 !mb%=w%(6,0) 23620 mb%!4-=88 23630 mb%!12=mb%!4+84 23640 SYS "Wimp_OpenWindow",,mb% 23650ENDIF 23660ENDPROC 23670 23680DEF PROCdeletegrabbed 23690IF NOT grabex% ENDPROC 23700saved8%=TRUE 23710saved12%=TRUE 23720cfsid%=FALSE 23730PROCdwin(5) 23740!grabwb=0 23750PROCdwin(6) 23760SYS "Wimp_SlotSize",originalslot%,-1 23770grabex%=FALSE 23780PROCiconset(4,1,1<<22,1<<22) 23790IF slave% THEN 23800 $mb%="<FastGrab$Dir>.Resources.TwelveBit" 23810 SYS "OS_FSControl",27,mb%,,0 23820 slave%=FALSE 23830ENDIF 23840ENDPROC 23850 23860DEF PROCpalette_for_sprite(sprite_area%,sprite_ad%,pal_ad%) 23870LOCAL paltemp% 23880DIM paltemp% 2048 23890 23900SYS "OS_SpriteOp",&228,sprite_area%,sprite_ad% TO ,,,sprite_x%,sprite_y%,sprite_mask%,sprite_mode% 23910 23920CASE sprite_ad%!32 OF 23930WHEN 44 23940 REM Use default palette for the screen mode 23950 SYS "ColourTrans_SelectTable",sprite_mode%,0,-1,-1,pal_ad% 23960WHEN 2048+44 23970 REM Use 256 grey level palette 23980 FOR grab%=0 TO 2048-8 STEP 8 23990 paltemp%!(grab%>>1)=sprite_ad%!(grab%+44) 24000 NEXT 24010 FOR Q%=0 TO 255 24020 SYS "ColourTrans_ReturnColourNumber",paltemp%!(Q%<<2) TO pal_ad%?Q% 24030 NEXT 24040OTHERWISE 24050 REM Use the sprite's palette 24060 FOR grab%=0 TO 164 STEP 8 24070 paltemp%!(grab%/2)=sprite_ad%!(grab%+44) 24080 NEXT 24090 SYS "ColourTrans_SelectTable",sprite_mode%,paltemp%,-1,-1,pal_ad% 24100ENDCASE 24110ENDPROC 24120 24130DEF PROCoptimise_liveplot 24140liveplot%=-1 24150FOR Q%=0 TO 255 24160 IF livepal%?Q%<>Q% liveplot%=livepal% 24170NEXT 24180livewb!24=liveplot% 24190!colmap=liveplot% 24200ENDPROC 24210 24220DEF PROCmodechanged 24230LOCAL xshift%,yshift%,sptr%,spmd%,grab%,palptr% 24240oldmode%=MODE 24250SYS "OS_ReadModeVariable",-1,4 TO ,,xshift% 24260SYS "OS_ReadModeVariable",-1,5 TO ,,yshift% 24270SYS "OS_ReadModeVariable",-1,11 TO ,,rightscr% 24280SYS "OS_ReadModeVariable",-1,12 TO ,,topscr% 24290rightscr%=rightscr%<<xshift% 24300topscr%=topscr%<<yshift% 24310SYS "Wimp_ReadPixTrans",&200,livearea%,livearea%+16,,,,livemag,mb% 24320IF w%(5,2) THEN 24330 PROCpalette_for_sprite(grabarea%,grabarea%+16,grabpal%) 24340 !mb%=w%(5,0) 24350 SYS "Wimp_GetWindowState",,mb% 24360 IF mb%!32 AND 1<<16 THEN 24370 grabwx%=gpx%<<xshift% 24380 grabwy%=gpy%<<yshift% 24390 PROCmagstring(0,0) 24400 ENDIF 24410ENDIF 24420PROCpalette_for_sprite(livearea%,livearea%+16,livepal%) 24430PROCoptimise_liveplot 24440ENDPROC 24450 24460DEF PROCupdatesprite 24470IF w%(3,2) THEN 24480 !mb%=w%(3,0) 24490 SYS "Wimp_UpdateWindow",,mb% TO more% 24500 x0%=mb%!4-mb%!20 24510 y0%=mb%!16-mb%!24 24520 WHILE more% 24530 SYS "OS_SpriteOp",&134,livearea%,livename$,x0%,y0%-livey%,8,0,livepal% 24540 SYS "Wimp_GetRectangle",,mb% TO more% 24550 ENDWHILE 24560ENDIF 24570ENDPROC 24580 24590DEF PROCsendhelp 24600h$="This window belongs to FastGrab."+CHR$0 24610CASE pb%!32 OF 24620WHEN -2 24630h$="This is the FastGrab icon.|MClick SELECT to see the live output from the Hawk V9 Colour digitiser.|MDrag a twelve bit image file onto it to process the image and display it.|M" 24640IF w%(3,2) THEN 24650IF !signalpresent h$+="The live display is working." ELSE h$+="There is no video signal at present." 24660ELSE 24670h$+="The live display is now dormant." 24680ENDIF 24690WHEN w%(2,0) 24700CASE pb%!36 OF 24710WHEN 4:h$="This slider bar controls the brightness of the picture from the Hawk V9." 24720WHEN 9:h$="This slider bar controls the contrast of the picture from the Hawk V9." 24730WHEN 14:h$="This slider bar controls the saturation of the picture from the Hawk V9." 24740WHEN 1,2,6,7,11,12 24750CASE pb%!36 OF 24760WHEN 1:bar$="brightness":act$="increase" 24770WHEN 2:bar$="brightness":act$="decrease" 24780WHEN 6:bar$="contrast":act$="increase" 24790WHEN 7:bar$="contrast":act$="decrease" 24800WHEN 11:bar$="saturation":act$="increase" 24810WHEN 12:bar$="saturation":act$="decrease" 24820ENDCASE 24830h$="Click on this icon to "+act$+" the "+bar$+" of the picture from the Hawk V9.|MClicking on it with adjust will have the opposite effect." 24840WHEN 0:h$="Click on this icon to reset the PAL decoder to its default settings." 24850WHEN 16:h$="Click on this icon to reset the PAL decoder to the settings saved on disc." 24860OTHERWISE h$="This window controls the PAL decoder, which adjusts the video image received from the Hawk V9 board." 24870ENDCASE 24880WHEN w%(3,0) 24890h$="This window shows the live display from the Hawk V9 Colour Digitiser." 24900IF !signalpresent=0 h$+="|MAt the moment there is no video signal, so the image is static." 24910WHEN w%(4,0) 24920CASE pb%!36 OF 24930WHEN 0:h$="Click on the camera icon to grab a frame from the Hawk V9 Colour Digitiser." 24940WHEN 1:h$="Click on the eye-con to view the stored frame." 24950WHEN 2:h$="Click on this icon to adjust the PAL decoder." 24960WHEN 3 24970 IF board_is_16_bit% THEN 24980 h$="Click on this icon to toggle between storing both 16 bit data and 8 bit data or just eight bit data." 24990 ELSE 25000 h$="Click on this icon to toggle between storing both 12 bit data and 8 bit data or just eight bit data." 25010 ENDIF 25020WHEN 4:h$="Click on this icon to toggle between dithered and non-dithered images." 25030ENDCASE 25040WHEN w%(5,0) 25050h$="This window shows a frame which has been captured by the Hawk V9 Colour Digitiser." 25060WHEN w%(6,0) 25070CASE pb%!36 OF 25080WHEN 0:h$="Click on this icon to process the image using the ChangeFSI routine.|MChangeFSI is included by courtesy of its author, Roger Wilson of Acorn Computers Limited." 25090WHEN 1:h$="Click on this icon to adjust the scale factors for the image.|MThis shows what will happen if SpriteExtend is used for scaling.|MThe ChangeFSI routine produces much better scaling, but it is a little slower." 25100WHEN 2:h$="Click on this icon to save the image as a Sprite file." 25110WHEN 3 25120 IF board_is_16_bit% THEN 25130 h$="Click on this icon to save the image as a Data file, in 16-bit video format." 25140 ELSE 25150 h$="Click on this icon to save the image as a Data file, in 12-bit video format." 25160 ENDIF 25170ENDCASE 25180WHEN w%(9,0) 25190CASE pb%!36 OF 25200WHEN -1:h$="This is the Zoom window.|MIt allows you to adjust the size of the display using the SpriteExtend scaling routines.|MUsing ChangeFSI gives better results but it is a little slower." 25210WHEN 0:h$="This number is the scaling multiplier.|MYou can either type a number in, or use the arrow icons to adjust it.|M" 25220WHEN 1:h$="This number is the scaling divisor.|MYou can either type a number in, or use the arrow icons to adjust it." 25230WHEN 2:h$="Click on this icon to increase the scaling multiplier.|MAdjust-click on it the decrease the value." 25240WHEN 3:h$="Click on this icon to decrease the scaling multiplier.|MAdjust-click on it to increase the value." 25250WHEN 4:h$="Click on this icon to increase the scaling divisor.|MAdjust-click on it to decrease the value." 25260WHEN 5:h$="Click on this icon to decrease the scaling divisor.|MAdjust-click on it to increase the value." 25270ENDCASE 25280WHEN w%(10,0) 25290h$="This window displays information about the current sprite image.|MIt may have less than eight bits per pixel if it has been processed using ChangeFSI." 25300CASE pb%!36 OF 25310WHEN 0:h$="This is the name of the sprite." 25320WHEN 1:h$="This is the screen mode in which the sprite was produced." 25330WHEN 2:h$="This tells you whether or not the sprite has a transparency mask." 25340WHEN 3:h$="This is the width of the sprite, in pixels." 25350WHEN 4:h$="This is the size of the sprite, in bytes." 25360WHEN 5:h$="This tells you whether or not the sprite has its own palette." 25370WHEN 6:h$="This is the height of the sprite, in pixels." 25380ENDCASE 25390WHEN w%(11,0) 25400h$="This window displays information about the twelve bit 'raw' data." 25410CASE pb%!36 OF 25420WHEN 1:h$="This is the size of the data, in bytes." 25430WHEN 3:h$="This is the width of the image, in pixels." 25440WHEN 5:h$="This is the height of the image, in pixels." 25450WHEN 9:h$="The image was grabbed at the brightness setting shown." 25460WHEN 10:h$="The image was grabbed at the saturation setting shown." 25470WHEN 11:h$="The image was grabbed at the contrast setting shown." 25480ENDCASE 25490WHEN w%(13,0) 25500h$="This window contains information on FastGrab's development." 25510CASE pb%!36 OF 25520WHEN 1,2:h$="FastGrab is a real time video grabbing system for use with RISC OS computers. It is designed to work with the Wild Vision Hawk V9 Real Time Colour Digitiser." 25530WHEN 3,4:h$="All original FastGrab code is by Robert W Hamilton @ Mercenary Software." 25540WHEN 5:h$="This is the Wild Vision logo." 25550WHEN 6:h$="FastGrab was written for Wild Vision." 25560WHEN 7 25570ds%=INSTR(version$,"(") 25580de%=INSTR(version$,")") 25590h$="This is "+LEFT$(version$,ds%-2)+" of FastGrab and it was last updated on "+MID$(version$,ds%+1,de%-ds%-1)+"." 25600ENDCASE 25610WHEN w%(14,0) 25620h$="This window gives some development information on the ChangeFSI program." 25630CASE pb%!36 OF 25640WHEN 1:h$="ChangeFSI takes its name from R W Floyd and L Steinberg, whose 'error diffusion' technique is used to improve output.|MThe 'I' is for integer, as the program uses this form of arithmetic." 25650WHEN 2:h$="Mercenary Software and Wild Vision would like to thank Roger Wilson, of Acorn Computers Limited, for his permission to use ChangeFSI in FastGrab." 25660ENDCASE 25670WHEN w%(1,0) 25680CASE pb%!36 OF 25690WHEN -1:h$="This parameters in this window are those used by the ChangeFSI image processing routine." 25700WHEN 0:h$="Enter the output mode to be used here. It should be a graphics mode - note that modes 2,4,5 and 10 are not supported. If you attempt to use an invalid mode, mode 15 will be used instead." 25710WHEN 1,2,3,4 25720CASE pb%!36 OF 25730WHEN 1:h$="This is the x output ratio." 25740WHEN 2:h$="This is the x input ratio." 25750WHEN 3:h$="This is the y output ratio." 25760WHEN 4:h$="This is the y input ratio." 25770ENDCASE 25780h$+="|MSet the scaling ratios as you do in Paint and Draw." 25790WHEN 5:h$="Select this icon to scale the output to fit the output mode." 25800WHEN 6:h$="Select this icon to use the scale ratios in the boxes." 25810WHEN 7:h$="Select this icon for standard output." 25820WHEN 8:h$="Select this icon for 2 or 4 bit colour, or for clustered dithering in one bit per pixel modes." 25830WHEN 9:h$="Select this icon for digital RGB output." 25840WHEN 10:h$="Select this icon for no tinting in 256 colour modes, or sixteen grey levels in 16 colour modes." 25850WHEN 11:h$="Select this icon to expand the dynamic range of the source.|MAdjust-clicking on this icon when it is selected will unselect it." 25860WHEN 12:h$="Select this icon to apply histogram equalisation to the source.|MAdjust-clicking on this icon when it is selected will unselect it." 25870WHEN 13:h$="Select this icon to process in Mode 0.|MThis will speed things up, especially if you are in a high-resolution mode for viewing the output." 25880WHEN 14:h$="Select this icon to invert the source before processing." 25890WHEN 15:h$="Select this icon to pre-sharpen the source." 25900WHEN 16:h$="Select this icon to omit ChangeFSI's pixel correction routines. This means that the size of the pixels is ignored when translating images." 25910WHEN 22:h$="Enter the value for sharpening here, in the range 8-31 (31=soft, 8=harsh)." 25920WHEN 23:h$="Select this icon to flip the image horizontally." 25930WHEN 24:h$="Select this icon to flip the image vertically." 25940WHEN 25:h$="Click on this icon to process the image with the current parameters." 25950WHEN 26:h$="Select this icon to disable dithering of the output image." 25960WHEN 27:h$="Select this icon to artificially brighten the output image." 25970WHEN 28:h$="Select this icon to apply black correction to the image before processing. This corrects for the size of black ink spots (eg on printers)." 25980WHEN 29:h$="Select this icon to apply gamma correction to the image before processing. " 25990WHEN 30:h$="Enter the value for black correction here, in the range 0-128 (0=not at all, 128=harsh)." 26000WHEN 31:h$="Enter the value for gamma correction here. The default value is 2.2." 26010ENDCASE 26020WHEN w%(17,0) 26030CASE pb%!36 OF 26040WHEN -1:h$="This window allows you to adjust the speed of FastGrab's live display." 26050WHEN 0:h$="This slider bar controls the speed of FastGrab's live display. 0 is the slowest speed, and 99 the fastest." 26060WHEN 1:h$="Click on this icon to increase the speed of FastGrab's live display.|MAdjust click on it to slow the display down." 26070WHEN 2:h$="Click on this icon to slow down FastGrab's live display.|MAdjust click on it to increase the speed of the display." 26080WHEN 3:h$="This field sets the speed of FastGrab's live display." 26090ENDCASE 26100ENDCASE 26110h$+=CHR$0 26120fnamelen%=LEN(h$) 26130PROCround(fnamelen%,4) 26140!mb%=20+fnamelen% 26150mb%!8=-1 26160mb%!12=pb%!8 26170mb%!16=&503 26180$(mb%+20)=h$ 26190SYS "Wimp_SendMessage",17,mb%,0 26200ENDPROC 26210DEF PROCsavesprite 26220IF INSTR($outsprad%,".")=0 ERROR 42,"To save, drag the icon to a directory viewer." 26230SYS "OS_SpriteOp",&10C,grabarea%,$outsprad% 26240saved8%=TRUE 26250IF cfsid% THEN $grabwtitlead%=$outsprad%+" CFSI" ELSE $grabwtitlead%=$outsprad%+"8 bit" 26260PROCupdatetitle 26270ENDPROC 26280DEF PROCsaveraw 26290IF INSTR($outrawad%,".")=0 ERROR 42,"To save, drag the icon to a directory viewer." 26300rawout%=OPENOUT($outrawad%) 26310IF slave% THEN 26320rawin%=OPENIN("<FastGrab$Dir>.Resources.TwelveBit") 26330IF rawin%=0 CLOSE#rawout%:ERROR 214,"Cache file not found" 26340SYS "OS_GBPB",4,rawin%,livearea%+100,100000 26350SYS "OS_GBPB",2,rawout%,livearea%+100,100000 26360SYS "OS_GBPB",4,rawin%,livearea%+100,96628 26370SYS "OS_GBPB",2,rawout%,livearea%+100,96628 26380ELSE 26390SYS "OS_GBPB",2,rawout%,rawarea%,rawsize% 26400ENDIF 26410CLOSE#rawout% 26420saved12%=TRUE 26430IF board_is_16_bit% $grabwtitlead%=$outrawad%+" 16 bit" ELSE $grabwtitlead%=$outrawad%+" 12 bit" 26440PROCupdatetitle 26450ENDPROC 26460DEF PROCupdatetitle 26470IF w%(5,2) THEN 26480!mb%=w%(5,0) 26490SYS "Wimp_GetWindowOutline",,mb% 26500SYS "Wimp_ForceRedraw",-1,mb%!4,mb%!16-48,mb%!12,mb%!16 26510ENDIF 26520ENDPROC 26530DEF PROCinstallonbar 26540!pb%=-1 26550pb%!4=0 26560pb%!8=0 26570pb%!12=68 26580pb%!16=68 26590pb%!20=%100000010 OR %10<<12 26600pb%!24=barspace 26610pb%!28=sprites% 26620pb%!32=11 26630SYS "Wimp_CreateIcon",,pb% TO iconbar% 26640!iconb=-1 26650iconb!4=iconbar% 26660ENDPROC 26670DEF PROCgst(block%,handle%) 26680!block%=handle% 26690SYS "Wimp_GetWindowState",,block% 26700ENDPROC 26710DEF FNopen(block%,handle%) 26720PROCgst(block%,handle%) 26730=block%!32 AND 1<<16 26740 26750DEF FNcmenu(level%,text$,width%) 26760LOCAL newtext$,title$,ptr%,shade%,tick%,dotted%,submenu%,writable%,rjust%,warnmenu% 26770IF level%=0 THEN 26780longpointer%=longitems% 26790mnb%=menub% 26800ELSE 26810mnb%+=maxmenusize% 26820ENDIF 26830title$=LEFT$(text$,INSTR(text$,"|")-1) 26840text$=MID$(text$,INSTR(text$,"|")+1) 26850$mnb%=LEFT$(title$,11) 26860mnb%?12=7 26870mnb%?13=2 26880mnb%?14=7 26890mnb%?15=0 26900mnb%!16=width% 26910mnb%!20=44 26920mnb%!24=0 26930IF RIGHT$(text$,1)<>"|" text$+="|" 26940ptr%=mnb%+28 26950REPEAT 26960shade%=0:tick%=0 26970dotted%=0:writable%=0 26980rjust%=0:submenu%=-1 26990warnmenu%=0 27000WHILE INSTR("<>:*'�#@",LEFT$(text$,1)) 27010CASE LEFT$(text$,1) OF 27020WHEN "<" 27030shade%=&400000 27040text$=MID$(text$,2) 27050WHEN ">" 27060tick%=1 27070text$=MID$(text$,2) 27080WHEN ":" 27090dotted%=2 27100text$=MID$(text$,2) 27110WHEN "*" 27120writable%=4 27130text$=MID$(text$,2) 27140WHEN "'" 27150text$=MID$(text$,2) 27160newtext$=EVAL(LEFT$(MID$(text$,5),INSTR(text$,"'")-1)) 27170width%=VAL(LEFT$(text$,4)) 27180text$=MID$(text$,INSTR(text$,"'")+1) 27190submenu%=FNcmenu(level%+1,newtext$,width%) 27200WHEN "�" 27210submenu%=VAL(MID$(text$,2,4)) 27220text$=RIGHT$(text$,LEN(text$)-5) 27230WHEN "#" 27240rjust%=1 27250text$=MID$(text$,2) 27260WHEN "@" 27270text$=MID$(text$,2) 27280warnmenu%=8 27290submenu%=VAL(LEFT$(text$,INSTR(text$,"'"))) 27300IF submenu%=0 submenu%=-1 27310text$=MID$(text$,INSTR(text$,"'")+1) 27320ENDCASE 27330ENDWHILE 27340IF writable% THEN 27350i%=INSTR(text$,",") 27360ptr%!12=EVAL(LEFT$(text$,i%-1)) 27370text$=MID$(text$,i%+1) 27380i%=INSTR(text$,",") 27390ptr%!16=EVAL(LEFT$(text$,i%-1)) 27400text$=MID$(text$,i%+1) 27410ptr%!20=EVAL(LEFT$(text$,INSTR(text$,"|"))) 27420ELSE 27430IF LEN(LEFT$(text$,INSTR(text$,"|")-1))>11 THEN 27440long%=1 27450$longpointer%=LEFT$(text$,INSTR(text$,"|")-1)+CHR$13 27460ptr%!12=longpointer% 27470ptr%!16=&FFFFFFFF 27480ptr%!20=LEN(LEFT$(text$,INSTR(text$,"|")-1)+CHR$13) 27490longpointer%+=LEN(LEFT$(text$,INSTR(text$,"|")-1)+CHR$13) 27500IF longpointer%>longitems%+longsp% ERROR 0,"Menu workspace exceeded" 27510ELSE 27520long%=0 27530$(ptr%+12)=LEFT$(LEFT$(text$,INSTR(text$,"|")-1),11) 27540ENDIF 27550ENDIF 27560text$=MID$(text$,INSTR(text$,"|")+1) 27570!ptr%=tick% OR dotted% OR writable% OR (&80 AND (text$="")) OR warnmenu% 27580ptr%!4=submenu% 27590ptr%!8=shade% OR writable%<<6 OR long%<<8 OR &010021 OR rjust%<<9 OR 7<<24 27600ptr%+=24 27610UNTIL text$="" 27620IF level%=0 SYS "Wimp_CreateMenu",0,menub%,mousex%-64,mousey% 27630=mnb% 27640 27650DEF PROCmenu(window%,x%,y%,sub%) 27660IF oldmenu%<>-1 AND oldmenu%<>window% PROCdwin(oldmenu%) 27670PROCcwin(window%) 27680IF sub% THEN 27690SYS "Wimp_CreateSubMenu",,w%(window%,0),x%,y% 27700ELSE 27710SYS "Wimp_CreateMenu",,w%(window%,0),x%,y% 27720ENDIF 27730oldmenu%=window% 27740ENDPROC 27750 27760DEF PROCmenuselect 27770LOCAL adjust% 27780SYS "Wimp_GetPointerInfo",,mouseb% 27790adjust%=mouseb%!8 AND 1 27800CASE mentype% OF 27810WHEN 0 27820 CASE !pb% OF 27830 WHEN 0 27840 adjust%=FALSE 27850 SYS "Wimp_CreateMenu",,-1 27860 PROCmenu(13,!mouseb%-64,mouseb%!4,0) 27870 WHEN 1 27880 PROCshutdown(-1) 27890 ENDCASE 27900WHEN 1 27910 CASE !pb% OF 27920 WHEN 0 27930 PROCgrab 27940 WHEN 1 27950 IF pb%!4>=0 THEN 27960 grabsize%=pb%!4 27970 grabsize$=FNsetsizemenu(grabsize%) 27980 ENDIF 27990 WHEN 2 28000 IF pb%!4>=0 THEN 28010 IF livesize%>pb%!4 THEN 28020 A%=livearea%+60 28030 B%=&20100 28040 CALLblank 28050 ENDIF 28060 livesize%=pb%!4 28070 PROCadjustlive 28080 livesize$=FNsetsizemenu(livesize%) 28090 ENDIF 28100 WHEN 3 28110 IF bit%=12 THEN 28120 bit%=8 28130 PROCiconset(4,3,1<<21,1<<21) 28140 ELSE 28150 bit%=12 28160 PROCiconset(4,3,1<<21,0) 28170 ENDIF 28180 WHEN 4 28190 dithered%=dithered% EOR 1 28200 PROCtoggle(dither$) 28210 PROCchange_LCA(dithered%) 28220 WHEN 5 28230 PROCtoggle(mono$) 28240 IF mono$=">" THEN 28250 PROClive_grey 28260 PROCiconset(4,3,1<<22,1<<22) 28270 PROCiconset(4,4,1<<22,1<<22) 28280 ELSE 28290 PROClive_colour 28300 PROCiconset(4,3,1<<22,0) 28310 PROCiconset(4,4,1<<22,0) 28320 ENDIF 28330 PROCchange_LCA(dithered%) 28340 WHEN 6 28350 CASE pb%!4 OF 28360 WHEN -1 28370 IF field$="" THEN 28380 field$=">" 28390 !fielding=1 28400 ELSE 28410 field$="" 28420 !fielding=0 28430 ENDIF 28440 WHEN 0 28450 IF field$="" THEN field$=">" 28460 !fielding=1 28470 !evenfield=0 28480 ELSE 28490 !fielding=0 28500 ENDIF 28510 WHEN 1 28520 IF field$="" THEN field$=">" 28530 !fielding=1 28540 !evenfield=1 28550 ELSE 28560 !fielding=0 28570 ENDIF 28580 ENDCASE 28590 PROCfieldmenu 28600 WHEN 7 28610 PROCtoggle(cache$) 28620 WHEN 8 28630 PROCshowgrab 28640 WHEN 10 28650 IF pb%!4<>-1 THEN 28660 SYS "OS_ReadModeVariable",VAL($modeb%),3 TO ,,ncol% 28670 IF ncol%<>63 THEN 28680 $(modeb%)="15" 28690 ERROR 42,"Not a 256 colour mode" 28700 ENDIF 28710 ENDIF 28720 WHEN 12 28730 PROCsavechoices 28740 WHEN 13 28750 IF ltool$="" THEN 28760 ltool$=">" 28770 !mb%=w%(3,0) 28780 SYS "Wimp_GetWindowState",,mb% 28790 PROCcwin(4) 28800 !mb%=w%(4,0) 28810 mb%!4-=88 28820 mb%!12=mb%!4+84 28830 mb%!20=0 28840 mb%!24=0 28850 SYS "Wimp_OpenWindow",,mb% 28860 ELSE 28870 ltool$="" 28880 PROCdwin(4) 28890 ENDIF 28900 ENDCASE 28910WHEN 2 28920 CASE !pb% OF 28930 WHEN 7 28940 adjust%=FALSE 28950 IF grab12% THEN 28960 IF NOT saved12% THEN 28970 PROCquery(1,"Do you want to save the raw data?") 28980 ELSE 28990 PROCdeletegrabbed 29000 ENDIF 29010 ELSE 29020 IF NOT saved8% THEN 29030 PROCquery(3,"Do you want to save the sprite?") 29040 ELSE 29050 PROCdeletegrabbed 29060 ENDIF 29070 ENDIF 29080 WHEN 8 29090 IF gtool$="" THEN 29100 gtool$=">" 29110 !mb%=w%(5,0) 29120 SYS "Wimp_GetWindowState",,mb% 29130 PROCcwin(6) 29140 !mb%=w%(6,0) 29150 mb%!4-=88 29160 mb%!12=mb%!4+84 29170 mb%!20=0 29180 mb%!24=0 29190 SYS "Wimp_OpenWindow",,mb% 29200 ELSE 29210 gtool$="" 29220 PROCdwin(6) 29230 ENDIF 29240 ENDCASE 29250ENDCASE 29260IF adjust% AND (NOT close%) THEN 29270 CASE mentype% OF 29280 WHEN 0 29290 menu%=FNcmenu(0,"FastGrab|@13'Info|Quit|",96) 29300 WHEN 1 29310 IF bit%=12 THEN 29320 tick12$=">" 29330 cachem$=cache$ 29340 ELSE 29350 tick12$="" 29360 cachem$="<" 29370 ENDIF 29380 IF grabex% shade$="" ELSE shade$="<" 29390 temp0$="FastGrab|Grab frame|'0156grabsize$'Frame size|'0156livesize$'Live size|" 29400 IF mono$=">" THEN ms$="<" ELSE ms$="" 29410 IF board_is_16_bit% THEN 29420 temp1$=ms$+tick12$+"16 bit data|"+ms$+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 29430 ELSE 29440 temp1$=tick12$+"12 bit data|"+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 29450 ENDIF 29460 menu%=FNcmenu(0,temp0$+temp1$,236) 29470 WHEN 2 29480 IF grab12% raw$="" ELSE raw$="<" 29490 temp0$="FastGrab|@10'Sprite info|@9'Zoom|@6'Save sprite|@1'"+raw$+"ChangeFSI|@14'Credits|" 29500 IF board_is_16_bit% THEN 29510 temp1$="@11'"+raw$+"16 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 29520 ELSE 29530 temp1$="@11'"+raw$+"12 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 29540 ENDIF 29550 menu%=FNcmenu(0,temp0$+temp1$,220) 29560 ENDCASE 29570ENDIF 29580ENDPROC 29590 29600DEF PROCtoggle(RETURN swap$) 29610IF swap$=">" THEN swap$="" ELSE swap$=">" 29620ENDPROC 29630 29640DEF PROCcwin(number%) 29650IF NOT w%(number%,2) THEN 29660 SYS "Wimp_CreateWindow",,w%(number%,1)+4 TO w%(number%,0) 29670 !w%(number%,1)=w%(number%,0) 29680 w%(number%,2)=TRUE 29690ENDIF 29700ENDPROC 29710 29720DEF PROCdwin(number%) 29730IF w%(number%,2) THEN 29740 SYS "Wimp_GetWindowInfo",,w%(number%,1) 29750 SYS "Wimp_DeleteWindow",,w%(number%,1) 29760 w%(number%,2)=FALSE 29770 w%(number%,0)=-1 29780ENDIF 29790ENDPROC 29800 29810DEF PROCclwin(number%) 29820IF w%(number%,2) THEN 29830 SYS "Wimp_GetWindowInfo",,w%(number%,1) 29840 SYS "Wimp_CloseWindow",,w%(number%,1) 29850ENDIF 29860ENDPROC 29870 29880DEF PROCfieldmenu 29890subfield$="Field|" 29900IF !fielding=0 THEN 29910 subfield$+="Even|Odd|" 29920ELSE 29930 IF !evenfield THEN 29940 subfield$+="Even|>Odd|" 29950 ELSE 29960 subfield$+=">Even|Odd|" 29970 ENDIF 29980ENDIF 29990ENDPROC 30000 30010DEF FNsetsizemenu(value%) 30020LOCAL size$ 30030CASE value% OF 30040WHEN 0 30050 size$=">512 � 256|256 � 128|128 � 64|" 30060WHEN 1 30070 size$="512 � 256|>256 � 128|128 � 64|" 30080WHEN 2 30090 size$="512 � 256|256 � 128|>128 � 64|" 30100WHEN 3 30110 size$="512 � 256|256 � 128|128 � 64|>" 30120OTHERWISE 30130 ERROR 0,"Invalid frame size" 30140ENDCASE 30150="Size|"+size$+" 64 � 32" 30160 30170DEF PROCmenuwarning 30180PROCmenu(pb%!20,pb%!24,pb%!28,-1) 30190ENDPROC 30200 30210DEF PROCsavechoices 30220outc%=OPENOUT("<FastGrab$Dir>.Resources.Choices") 30230BPUT#outc%,VAL$modead% 30240PRINT#outc%,$x1ad% 30250PRINT#outc%,$y1ad% 30260PRINT#outc%,$x2ad% 30270PRINT#outc%,$y2ad% 30280CASE outmode$ OF 30290WHEN " " 30300 outset%=0 30310WHEN "C" 30320 outset%=1 30330WHEN "D" 30340 outset%=2 30350WHEN "T" 30360 outset%=3 30370WHEN "P" 30380 outset%=0:REM Cannot be used here! 30390ENDCASE 30400BPUT#outc%,outset% OR FNselected(11)<<2 OR FNselected(12)<<3 OR FNselected(13)<<4 OR FNselected(14)<<5 OR FNselected(15)<<6 OR FNselected(16)<<7 30410BPUT#outc%,FNselected(5) OR FNselected(23)<<1 OR FNselected(24)<<2 OR FNselected(25)<<3 OR FNselected(27)<<4 30420BPUT#outc%,VAL($sharpenad%) 30430BPUT#outc%,brightness% 30440savedbright%=brightness% 30450BPUT#outc%,contrast% 30460savedcont%=contrast% 30470IF mono$=">" THEN 30480 BPUT#outc%,old_sat% 30490ELSE 30500 BPUT#outc%,saturation% 30510ENDIF 30520savedsat%=saturation% 30530BPUT#outc%,ABS(bit%=12) OR ABS(ltool$=">")<<1 OR ABS(gtool$=">")<<2 OR ABS(cache$=">")<<3 OR ABS(field$=">")<<4 OR !evenfield<<5 OR dithered%<<6 OR ABS(mono$=">")<<7 30540BPUT#outc%,speed% 30550BPUT#outc%,VAL($modeb%) 30560BPUT#outc%,grabsize% 30570BPUT#outc%,livesize% 30580BPUT#outc%,FNselected(26) 30590BPUT#outc%,FNselected(27) 30600BPUT#outc%,FNselected(28) 30610BPUT#outc%,VAL$blackad% 30620BPUT#outc%,FNselected(29) 30630PRINT#outc%,$gammaad% 30640BPUT#outc%,FNselected(32) 30650CLOSE#outc% 30660ENDPROC 30670 30680DEF PROCerror(arg%) 30690IF arg% THEN 30700 PROCcloseopen(c%) 30710 IF MODE<>oldmode% SYS "Wimp_SetMode",oldmode% 30720 !mb%=0 30730ENDIF 30740CASE ERR OF 30750WHEN &1E6 30760 flags%=1 30770 $(mb%+4)="FastGrab requires the Wild Vision Hawk V9 and its module to be present." 30780WHEN 11 30790 IF debug% THEN 30800 flags%=2 30810 $(mb%+4)="It's fallen over at line "+STR$(ERL)+" "+REPORT$ 30820ELSE 30830 flags%=1 30840 $(mb%+4)="Cannot claim enough memory to process image" 30850ENDIF 30860WHEN 42 30870 flags%=1 30880 $(mb%+4)=REPORT$ 30890WHEN 214 30900 flags%=1 30910 $(mb%+4)=REPORT$ 30920WHEN 223,183 30930 flags%=1 30940 $(mb%+4)="Unexpected end of file" 30950WHEN 643 30960 flags%=1 30970 $(mb%+4)="Too many windows have been created" 30980WHEN 1800 30990 flags%=1 31000 $(mb%+4)="Cannot grab in this mode - using mode 15 instead" 31010 grabarea%!56=15 31020WHEN &108C2 31030 $(mb%+4)="File open - could not save file" 31040 flags%=1 31050WHEN &10C85 31060 $(mb%+4)="Types don't match" 31070 flags%=1 31080WHEN &108C6 31090 $(mb%+4)="Disc full - could not save file" 31100 flags%=1 31110WHEN &108CC 31120 $(mb%+4)="Bad name - could not save file" 31130 flags%=1 31140WHEN &108D6 31150 $(mb%+4)="Directory not found - could not save file" 31160 flags%=1 31170OTHERWISE 31180 $(mb%+4)=REPORT$+" (Internal error :MSE#5"+STR$ERL+") "+STR$ERR 31190 flags%=2 31200 arg%=0 31210ENDCASE 31220IF flags% THEN 31230 SYS "Wimp_ReportError",mb%,flags%,"FastGrab" TO ,response% 31240 IF arg%=0 PROCshutdown(0) 31250 IF response%=2 PROCshutdown(-1) 31260ENDIF 31270ENDPROC 31280 31290DEF PROCcloseopen(RETURN handle%) 31300IF handle% CLOSE#handle% 31310handle%=0 31320ENDPROC 31330 31340DEF PROCassemble 31350DIM code% 4096,L% 0 31360FOR opt%=8 TO 10 STEP 2 31370P%=code% 31380[ 31390OPT opt% 31400.pollcode 31410MOV R12,R14 31420.fastloop 31430SWI "OS_ReadMonotonicTime" 31440LDR R1,speedval 31450ADD R2,R0,R1 31460MOV R11,#1 31470LDR R3,dragging% 31480CMP R3,#0 31490LDREQ R1,speedval 31500ADDEQ R2,R0,R1 31510LDR R0,maskad 31520LDR R1,pollad 31530SWIEQ "Wimp_PollIdle" 31540SWINE "Wimp_Poll" 31550CMP R0,#0 31560MOVEQ R11,#0 31570BLEQ updatecode 31580CMP R0,#1 31590MOVEQ R11,#0 31600BLEQ redrawhandler 31610CMP R11,#1 31620BNE fastloop 31630MOVS PC,R12 31640.pollad 31650EQUD 0 31660.speedval 31670EQUD 0 31680.redrawhandler 31690LDR R3,[R1] 31700STR R3,rdb 31710ADR R10,windowlist 31720.lookup 31730LDR R4,[R10] 31740CMP R3,R4 31750BEQ skip 31760CMP R4,#&20 31770MOVEQS PC,R12 31780ADD R10,R10,#28 31790B lookup 31800.skip 31810ADR R1,rdb 31820SWI "Wimp_RedrawWindow" 31830LDMIA R1,{R2-R8} 31840SUB R9,R6,R8 31850SUB R8,R3,R7 31860.redrawloop 31870CMP R0,#0 31880MOVEQS PC,R14 31890MOV R0,#&234 31900LDMIB R10,{R1-R4,R6,R7} 31910ADD R3,R3,R8 31920ADD R4,R4,R9 31930MOV R5,#0 31940SWI "OS_SpriteOp" 31950ADR R1,rdb 31960SWI "Wimp_GetRectangle" 31970B redrawloop 31980MOVS PC,R14 31990.updatecode 32000ADR R0,stack 32010;STMIA R0,{R2-R14} 32020STMIA R0,{R12,R14} 32030BL live_grab 32040ADR R0,stack 32050LDMIA R0,{R12,R14} 32060;LDMIA R0,{R2-R14} 32070MOV R0,#0 32080STR R0,udb+4 32090STR R0,udb+16 32100LDR R0,livexsize 32110STR R0,udb+12 32120LDR R0,liveysize 32130STR R0,udb+8 32140ADR R1,udb 32150SWI "Wimp_UpdateWindow" 32160LDMIA R1,{R2-R8} 32170SUB R9,R6,R8 32180SUB R8,R3,R7 32190.updateloop 32200CMP R0,#0 32210BEQ skipupdate 32220MOV R0,#&234 32230LDR R1,spritearea 32240LDR R2,spritead 32250MOV R3,#0 32260LDR R4,livewb+16 32270ADD R3,R3,R8 32280ADD R4,R4,R9 32290MOV R5,#0 32300ADR R6,livemag 32310LDR R7,colmap 32320SWI "OS_SpriteOp" 32330ADR R1,udb 32340SWI "Wimp_GetRectangle" 32350B updateloop 32360.skipupdate 32370LDR R1,dragging% 32380CMP R1,#0 32390MOVNE PC,R12 32400MOV PC,R14 32410.livemag 32420EQUD 1 32430EQUD 1 32440EQUD 1 32450EQUD 1 32460.rdb 32470EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32480EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32490.stack 32500EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32510EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32520EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32530.maskad 32540EQUD 0 32550.windowlist 32560.livewb 32570EQUD w%(3,0) 32580EQUD livearea% 32590EQUD livearea%+16 32600EQUD 0 32610EQUD -512 32620EQUD 0 32630EQUD 0 32640.grabwb 32650EQUD w%(5,0) 32660EQUD 0 32670EQUD 0 32680EQUD 0 32690EQUD -1024 32700EQUD 0 32710EQUD 0 32720EQUD &20 32730.livexsize 32740EQUD 0 32750.liveysize 32760EQUD 0 32770.udb 32780EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32790EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 32800.spritearea 32810EQUD 0 32820.spritead 32830EQUD 0 32840.colmap 32850EQUD 0 32860.dragging% 32870EQUD 0 32880.unpack 32890ADD R2,R0,#768 32900MOV R4,#&F 32910.unpackloop 32920LDR R3,[R0],#4 32930MOV R5,#0 32940.bitloop 32950AND R6,R3,R4,LSL R5 32960MOV R6,R6,LSR R5 32970ADD R5,R5,#4 32980AND R7,R3,R4,LSL R5 32990MOV R7,R7,LSR R5 33000ADD R5,R5,#4 33010STRB R7,[R1],#1 33020STRB R6,[R1],#1 33030CMP R5,#32 33040BNE bitloop 33050CMP R2,R0 33060BNE unpackloop 33070MOVS PC,R14 33080.blank 33090MOV R2,#0 33100ADD R1,R0,R1 33110.blankloop 33120STR R2,[R0],#4 33130CMP R0,R1 33140BLT blankloop 33150MOVS PC,R14 33160] 33170NEXT 33180grabwb!24=grabpal% 33190ENDPROC 33200 33210DEF FNChangeFSIVersion="0.82 (5 Feb 91)" 33220 33230DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%,fast%,V9Area%) 33240LOCAL A$(),r%(),g%(),b%(),rpal%(),gpal%(),bpal%(),table%(),cl%(),xl%(),xl2%() 33250LOCAL xp%(),rm%(),rm1%(),rm2%(),vals%(),nl%(),A%(),B%(),new%(),st%() 33260WHILELEFT$(A$,1)<>" "ANDLENA$<>0 A$=MID$(A$,2):ENDWHILE 33270WHILELEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE 33280WHILERIGHT$(A$,1)=" " A$=LEFT$(A$):ENDWHILE 33290IFFNuc(LEFT$(A$,5))="-QUIT" THEN 33300A$=MID$(A$,7):WHILELEFT$(A$,1)<>" "ANDLENA$<>0 A$=MID$(A$,2):ENDWHILE 33310WHILELEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE 33320ENDIF 33330DIM A$(100):ARG%=0:B%=INSTR(A$," ") 33340WHILE B%<>0 33350ARG%+=1:A$(ARG%)=LEFT$(A$,B%-1):A$=MID$(A$,B%+1) 33360WHILE LEFT$(A$,1)=" ":A$=MID$(A$,2):ENDWHILE 33370B%=INSTR(A$," ") 33380ENDWHILE 33390IFA$<>"" ARG%+=1:A$(ARG%)=A$ 33400 33410invert%=FALSE:range%=FALSE:sharpen%=FALSE:info%=FALSE:dither%=TRUE:black%=FALSE 33420hist%=FALSE:equal%=FALSE:vflip%=FALSE:hflip%=FALSE:scale%=TRUE:scaleo%=TRUE 33430gamma=1:rotate%=FALSE:max%=20000000:bright%=15 33440rwt=.30:gwt=.59:bwt=.11 33450IFARG%<3 THEN 33460PRINT"ChangeFSI interactive input [try 'ChangeFSI -help' for command line]" 33470INPUT"Source file: "s$,"Destination file: "f$,"Output mode: "m$ 33480INPUT"(X)Scale (e.g. 2:1): "xs$:INPUT"Y Scale: "ys$ 33490INPUT"Info on input picture?"a$:IFFNuc(LEFT$(a$,1))="Y" info%=TRUE 33500INPUT"Invert picture colours?"a$:IFFNuc(LEFT$(a$,1))="Y" invert%=TRUE 33510INPUT"Compute histogram of input?"a$:IFFNuc(LEFT$(a$,1))="Y" hist%=TRUE 33520INPUT"Apply histogram equalisation?"a$:IFFNuc(LEFT$(a$,1))="Y" equal%=TRUE 33530INPUT"Expand input dynamic range?"a$:IFFNuc(LEFT$(a$,1))="Y" range%=TRUE:equal%=FALSE 33540INPUT"Sharpen picture by (e.g. 12 for harsh, 24 for soft) "a$ 33550IFa$<>"" sharpen%=VALa$ 33560INPUT"Rotate?"a$:IFFNuc(LEFT$(a$,1))="Y" rotate%=TRUE 33570ELSE 33580REPEAT A%=ARG% 33590IFFNuc(A$(ARG%))="-INFO" info%=TRUE:A$(ARG%)="":ARG%-=1 33600IFFNuc(A$(ARG%))="-HIST" hist%=TRUE:A$(ARG%)="":ARG%-=1 33610IFFNuc(A$(ARG%))="-EQUAL" equal%=TRUE:range%=FALSE:A$(ARG%)="":ARG%-=1 33620IFFNuc(A$(ARG%))="-RANGE" range%=TRUE:equal%=FALSE:A$(ARG%)="":ARG%-=1 33630IFFNuc(A$(ARG%))="-INVERT" invert%=TRUE:A$(ARG%)="":ARG%-=1 33640IFFNuc(A$(ARG%))="-NOSCALE" scale%=FALSE:scaleo%=FALSE:A$(ARG%)="":ARG%-=1 33650IFFNuc(A$(ARG%))="-NOSIZE" scale%=FALSE:A$(ARG%)="":ARG%-=1 33660IFFNuc(A$(ARG%))="-NODITHER" dither%=FALSE:A$(ARG%)="":ARG%-=1 33670IFFNuc(A$(ARG%))="-BRIGHTEN" bright%=16:A$(ARG%)="":ARG%-=1 33680IFFNuc(A$(ARG%))="-ROTATE" rotate%=TRUE:A$(ARG%)="":ARG%-=1 33690IFFNuc(A$(ARG%))="-VFLIP" vflip%=TRUE:A$(ARG%)="":ARG%-=1 33700IFFNuc(A$(ARG%))="-HFLIP" hflip%=TRUE:A$(ARG%)="":ARG%-=1 33710IFFNuc(A$(ARG%))="-NOMODE" fast%=FALSE:A$(ARG%)="":ARG%-=1 33720IFFNuc(LEFT$(A$(ARG%),6))="-BLACK" THEN 33730black%=32:IFLENA$(ARG%)>6 black%=VALMID$(A$(ARG%),7):IFblack%>128 black%=128 33740A$(ARG%)="":ARG%-=1 33750ENDIF 33760IFFNuc(LEFT$(A$(ARG%),6))="-GAMMA" THEN 33770gamma=2.2:IFLENA$(ARG%)>6 gamma=VALMID$(A$(ARG%),7) 33780A$(ARG%)="":ARG%-=1 33790ENDIF 33800IFFNuc(LEFT$(A$(ARG%),8))="-SHARPEN" THEN 33810sharpen%=TRUE:IFLENA$(ARG%)>8 sharpen%=VALMID$(A$(ARG%),9) 33820A$(ARG%)="":ARG%-=1 33830ENDIF 33840IFFNuc(LEFT$(A$(ARG%),4))="-RED" rwt=VALMID$(A$(ARG%),5):A$(ARG%)="":ARG%-=1 33850IFFNuc(LEFT$(A$(ARG%),6))="-GREEN" gwt=VALMID$(A$(ARG%),7):A$(ARG%)="":ARG%-=1 33860IFFNuc(LEFT$(A$(ARG%),5))="-BLUE" bwt=VALMID$(A$(ARG%),6):A$(ARG%)="":ARG%-=1 33870IFFNuc(LEFT$(A$(ARG%),4))="-MAX" THEN 33880max%=VALMID$(A$(ARG%),5):IFINSTR(A$(ARG%),"K")ORINSTR(A$(ARG%),"k") max%=max%*1024 33890A$(ARG%)="":ARG%-=1 33900ENDIF 33910UNTILA%=ARG% 33920s$=A$(1):f$=A$(2):m$=A$(3):xs$=A$(4):ys$=A$(5) 33930ENDIF 33940IFokinfo% ELSEinfo%=FALSE 33950IFworkspace%>=0 THEN 33960flex%=FALSE 33970ELSE 33980IFworklimit%=0 THENflex%=FALSE ELSEflex%=TRUE:nextlocation%=worklimit% 33990ENDIF 34000pnm$=FNuc(m$):CASE pnm$ OF 34010WHEN"AIM":m=-1:m$="" 34020WHEN"P1":m=-2:m$="":spm=18 34030WHEN"P4":m=-2:m$="":spm=18 34040WHEN"P2":m=-2:m$="T":spm=20 34050WHEN"P5":m=-2:m$="T":spm=20 34060OTHERWISE:m=VALm$:spm=m:m$=FNuc(RIGHT$(m$,1)):IFINSTR("CDTP",m$)=0 m$="" 34070ENDCASE 34080IFxs$="" OR LEFT$(xs$,1)="-" THEN 34090xmul%=1:xdiv%=1:ymul%=1:ydiv%=1 34100ELSE 34110IFys$="" ys$=xs$ 34120xmul%=VALxs$:xdiv%=VALMID$(xs$,INSTR(xs$,":")+1) 34130ymul%=VALys$:ydiv%=VALMID$(ys$,INSTR(ys$,":")+1) 34140ENDIF 34150dir=FALSE 34160REM flag=-1:SYS8,5,s$ TO r0,,r2:dir=r0=2 34170IFdir THEN 34180panic=TRUE:SYS8,5,s$+".raw" TO r0,,r2:IFr0=1 s$+=".raw":dir=FALSE:panic=FALSE 34190IFpanic SYS8,5,s$+".red" TO r0,,r2:IFr0=1 panic=FALSE 34200IFpanic ERROR 42,"Directory given" 34210ENDIF 34220ftype=r2>>8 AND &FFF:bits=28:F=2^bits:c%=0:cc%=0:ccc%=0:o%=0 34230IFdir THEN 34240c%=OPENIN(s$+".red"):IFc%=0 ERROR 42,"Red file "+s$+".red not found" 34250cc%=OPENIN(s$+".green"):IFcc%=0 ERROR42,"Green file "+s$+".green not found" 34260ccc%=OPENIN(s$+".blue"):IFccc%=0 ERROR42,"Blue file "+s$+".blue not found" 34270ELSE 34280REM c%=OPENINs$:IFc%=0 ERROR 42,"File "+s$+" not found" 34290ENDIF 34300DIM r%(255) 34310DIM g%(255),b%(255) 34320CASE ftype OF 34330WHEN &FF9:flag=0 34340OTHERWISE 34350REM PTR#c%=0:S$="":FORI%=1TO8:S$+=CHR$BGET#c%:NEXT 34360REM IFflag=-1 IFS$="MercSoft" flag=902 34370REM flag=902:REM My format or else! !! fIX THIS !! 34380IF in_file_bits%=16 THEN flag=903 ELSE flag=902 34390ENDCASE 34400IFflag=-1:ERROR 42,"Sorry: format not recognised - please try again or contact your supplier" 34410step24=1:input=8:ham=0:planar%=0:bigendianbits=FALSE 34420compression=0:rflag=flag:cache%=FALSE:striprows%=-1:cachebytes%=FALSE 34430CASE flag OF 34440WHEN 0 34450quant%=4:PTR#c%=4:F%=FNW+&1C:PTR#c%=F%:st%=FNW+F%-&20:PTR#c%=F%+8 34460sm=FNW:SYS53,sm,3 TO ,,I% 34470CASE I% OF 34480WHEN 1:IFst%=F%+12 PROCdefpal2 ELSEPROCipal(2) 34490PTR#c%=F%-16:sx%=(FNW+1)*32:rowbytes%=sx%>>3:input=1 34500WHEN 3:IFst%=F%+12 PROCdefpal4 ELSEPROCipal(4) 34510PTR#c%=F%-16:sx%=(FNW+1)*16:rowbytes%=sx%>>2:input=2 34520WHEN 15:IFst%=F%+12 PROCdefpal16 ELSEPROCipal(16) 34530PTR#c%=F%-16:sx%=(FNW+1)*8:rowbytes%=sx%>>1:input=4 34540WHEN 63:IFst%=F%+12 PROCdefpal ELSEPROCipal63 34550PTR#c%=F%-16:sx%=(FNW+1)*4:rowbytes%=sx% 34560OTHERWISE ERROR42,"Not understood RISC OS sprite" 34570ENDCASE 34580sy%=FNW+1:PTR#c%=st%:cache%=TRUE 34590SYS53,sm,4 TO ,,nx:SYS53,sm,5 TO ,,ny:nx=1<<nx:ny=1<<ny 34600IFscale% xmul%=xmul%*nx/2:ymul%=ymul%*ny/2 34610offset%=0 34620info$="RISC OS sprite, mode "+STR$sm+" "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 34630 34640WHEN 900 34650quant%=8:sx%=256:sy%=256:st%=0:PTR#c%=0:IFscale% ymul%=ymul%*2:xmul%=xmul%*2 34660FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%():rowbytes%=sx%:rflag=0:cache%=TRUE 34670info$="AIM .raw image, 256 by 256 pixels, 8 bits per pixel" 34680 34690WHEN 901 34700quant%=4:sx%=256:sy%=256:IFscale% ymul%=ymul%*2:xmul%=xmul%*2 34710buff%=FNdim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+sx%*2 34720FORC%=0TO255:r%(C%)=(C%AND&F0)/&F0*F:NEXT:g%()=r%():b%()=r%() 34730input=24:info$="Hawk V9 Triple image, 256 by 256 pixels, 12 bits per pixel" 34740 34750WHEN 902 34760 offset%=20 34770 IF slave% THEN 34780 c%=OPENIN("<FastGrab$Dir>.Resources.TwelveBit") 34790 IF c%=0 ERROR 214,"Cache file cannot be found" 34800 offset%=20 34810 PTR#c%=20 34820 DIM tspace% 1024 34830 ENDIF 34840quant%=4 34850sx%=512 34860rowbytes%=sx%*3/2 34870sy%=256 34880st%=20 34890PROCsize 34900buff%=FNdim(sx%*3) 34910rb%=buff%:gb%=buff%+sx%:bb%=buff%+sx%*2:rats%=FNdim(rowbytes%) 34920FORC%=0TO255:r%(C%)=(C%AND&F)/&F*F:NEXT:g%()=r%():b%()=r%() 34930input=24:info$="Hawk V9 Colour image, "+STR$sx%+" by "+STR$sy%+" pixels, 12 bits per pixel" 34940 34950WHEN 903 34960 offset%=20 34970 IF slave% THEN 34980 c%=OPENIN("<FastGrab$Dir>.Resources.TwelveBit") 34990 IF c%=0 ERROR 214,"Cache file cannot be found" 35000 offset%=20 35010 PTR#c%=20 35020 DIM tspace% 1024 35030 ENDIF 35040quant%=5 35050sx%=512 35060rowbytes%=sx%*2 35070sy%=256 35080st%=20 35090PROCsize 35100buff%=FNdim(sx%*3) 35110rb%=buff%:gb%=buff%+sx%:bb%=buff%+sx%*2:rats%=FNdim(rowbytes%) 35120FOR C%=0 TO 255:r%(C%)=(C%AND&1F)/&1F*F:NEXT:g%()=r%()*1.6:b%()=r%() 35130input=24:info$="Hawk V9 Mk II Colour image, "+STR$sx%+" by "+STR$sy%+" pixels, 16 bits per pixel" 35140 35150ENDCASE 35160IFinfo% PRINTinfo$ 35170SYS"Hourglass_On",1:hour%=&406c4 35180IFinvert% r%()=F-r%():g%()=F-g%():b%()=F-b%() 35190CASE m OF 35200WHEN -1:x%=256:y%=256:ncol=255:IFscaleo% xdiv%=xdiv%*2:ydiv%=ydiv%*2 35210WHEN -2:x%=sx%:y%=sy%:IFspm=18 ncol=1 ELSEncol=15 35220OTHERWISE 35230SYS53,m,4 TO ,,nx:SYS53,m,5 TO ,,ny:nx=1<<nx:ny=1<<ny 35240SYS53,m,11 TO ,,x%:SYS53,m,12 TO ,,y%:x%+=1:y%+=1 35250SYS53,m,3 TO ,,ncol:IFscaleo% THEN 35260IFrotate% THEN 35270xdiv%=xdiv%*ny/2:ydiv%=ydiv%*nx/2 35280ELSE 35290xdiv%=xdiv%*nx/2:ydiv%=ydiv%*ny/2 35300ENDIF 35310ENDIF 35320ENDCASE 35330IFm$="P" THEN 35340J%=4096:IFncol<63 J%+=(ncol+1)*4 35350lookup%=FNdim(J%):palette%=lookup%+4096 35360I%=OPENIN("<FastGrab$Dir>.Resources.CFSIict"+STR$ncol) 35370IFI% THEN 35380CLOSE#I%:OSCLI"load <FastGrab$Dir>.Resources.CFSIict"+STR$ncol+" "+STR$~lookup% 35390ELSE 35400I%=&40744:FORB%=0TO15:SYShour%,B%*100DIV16 35410FORG%=0TO15:L%=(B%<<8 OR G%<<4)+lookup% 35420C%=B%<<28ORB%<<24 OR G%<<20ORG%<<16 35430FORR%=0TO15:SYSI%,C%OR R%<<12ORR%<<8 TO L%?R%:NEXT 35440NEXT:NEXT 35450IFncol<63 THEN 35460FORI%=0TOncol:SYS"OS_ReadPalette",I%,16 TO ,,palette%!(I%<<2):NEXT 35470ENDIF 35480I%=OPENOUT("<FastGrab$Dir>.Resources.CFSIict"+STR$ncol) 35490FORB%=0TOJ%-1:BPUT#I%,lookup%?B%:NEXT 35500CLOSE#I% 35510ENDIF 35520ENDIF 35530IFfast% IFMODE<>0 MODE0 35540IFrotate% SWAP x%,y%:SWAP xmul%,ymul% 35550IFxdiv%=0 xdiv%=sx% 35560IFydiv%=0 ydiv%=sy% 35570IFxs$="=" xmul%=x%:xdiv%=sx% 35580IFys$="=" ymul%=y%:ydiv%=sy% 35590IFncol=1 THEN 35600CASE m$ OF 35610WHEN"C":xdiv%=xdiv%*4:ydiv%=ydiv%*4 35620DIM A%(16),B%(16) 35630A%()=0,&00000001,&08000001,&08000101,&08080101,&08080103,&0C080103,&0C080303,&0C0C0303,&0C0E0303,&0C0E0703,&0E0E0703,&0E0E0707,&0E0F0707,&0E0F0F07,&0F0F0F07,&0F0F0F0F 35640B%()=0,&00000008,&01000008,&01000808,&01010808,&0101080C,&0301080C,&03010C0C,&03030C0C,&03070C0C,&03070E0C,&07070E0C,&07070E0E,&070F0E0E,&070F0F0E,&0F0F0F0E,&0F0F0F0F 35650even_gard=FNdim(17*32*4):odd_gard=FNdim(17*32*4) 35660FORI%=0TO16:FORJ%=0TO16:even_gard!(J%*32*4+I%*4)=A%(I%)ORB%(J%)<<4:NEXT:NEXT 35670FORI%=0TO16:FORJ%=0TO16:odd_gard!(I%*32*4+J%*4)=B%(I%)ORA%(J%)<<4:NEXT:NEXT 35680WHEN"T":xdiv%=xdiv%*3:ydiv%=ydiv%*3 35690DIM A%(9),B%(9) 35700A%()=0,&0001,&4001,&4041,&4043,&40C3,&60C3,&61C3,&71C3,&71C7 35710B%()=0,&0004,&1004,&1104,&1106,&1186,&3186,&31C6,&71C6,&71C7 35720even_gard=FNdim(10*16*4):odd_gard=FNdim(10*16*4) 35730FORI%=0TO9:FORJ%=0TO9:even_gard!(J%*16*4+I%*4)=A%(I%)ORB%(J%)<<3:NEXT:NEXT 35740FORI%=0TO9:FORJ%=0TO9:odd_gard!(I%*16*4+J%*4)=B%(I%)ORA%(J%)<<3:NEXT:NEXT 35750WHEN"D":xdiv%=xdiv%*2:ydiv%=ydiv%*2 35760DIM A%(4),B%(4) 35770A%()=0,&1,&21,&31,&33 35780B%()=0,&2,&12,&32,&33 35790even_gard=FNdim(5*8):odd_gard=FNdim(5*8) 35800FORI%=0TO4:FORJ%=0TO4:even_gard?(J%*8+I%)=A%(I%)ORB%(J%)<<2:NEXT:NEXT 35810FORI%=0TO4:FORJ%=0TO4:odd_gard?(I%*8+J%)=B%(I%)ORA%(J%)<<2:NEXT:NEXT 35820ENDCASE 35830ENDIF 35840PROCreduce(xmul%,xdiv%):PROCreduce(ymul%,ydiv%) 35850IFinfo% PRINT"Size ratios are x ";xmul%":"xdiv%" y "ymul%":"ydiv% 35860x%=sx%*xmul%/xdiv%+.9999:y%=sy%*ymul%/ydiv%+.9999:rows%=sy% 35870order%=x%*y%>sx%*sy% 35880CASE m OF 35890WHEN -1:col=0 35900OTHERWISE 35910IFm$="D" IFncol<>15 ANDncol<>1 m$="" 35920col=0:IFncol>15 OR m$="C" OR m$="D" OR m$="P" col=2 35930ENDCASE 35940IFncol=1 THEN 35950CASE m$ OF 35960WHEN"C":col=0:x%=x%+1ANDNOT1 35970WHEN"D":col=0:x%=x%+3ANDNOT3 35980WHEN"T":col=0:x%=x%+1ANDNOT1 35990ENDCASE 36000ENDIF 36010IFsharpen%=TRUE sharpen%=24 36020DIM cl%(x%+7,col) 36030DIM xl%(x%+7,col),xp%(sx%+7,col) 36040DIM xl2%(x%+7,col) 36050IFsharpen% THEN 36060IForder% THEN 36070DIM rm%(sx%+7,col),rm1%(sx%+7,col),rm2%(sx%+7,col) 36080ELSE 36090DIM rm%(x%+7,col),rm1%(x%+7,col),rm2%(x%+7,col) 36100ENDIF 36110ENDIF 36120IFhist%ORequal% DIM vals%(256,col) 36130DIM nl%(x%+7,col) 36140totvals%=x%*(col+1) 36150totvals2%=sx%*(col+1) 36160code%=FNdim(8192):SP=13 36170IFcache% THEN 36180SYS&20023,"ChangeFSI$Cache",code%,-1 TO,,Z 36190IFZ<>0 THEN 36200SYS35,"ChangeFSI$Cache",code%,20 TO,,Z:code%?Z=13:cache%=VAL$code% 36210IFINSTR($code%,"K")ORINSTR($code%,"k") cache%=cache%*1024 36220ELSE 36230cache%=8192 36240ENDIF 36250IFcachebytes% THEN 36260filesize%=EXT#c%-PTR#c%:IFcache%>filesize% cache%=filesize% 36270cacherows%=cache% 36280ELSE 36290filesize%=sy%*rowbytes%:IFcache%<rowbytes% cache%=rowbytes% 36300IFcache%>filesize% cache%=filesize% 36310cacherows%=striprows%:IFcacherows%<1 cacherows%=cache%DIVrowbytes% 36320cache%=cacherows%*rowbytes% 36330ENDIF 36340datacache%=FNdim(cache%):PROCrefill:IFcache%>=filesize% rowstogo%=-1 36350ENDIF 36360FORZ=0TO2STEP2:P%=code% 36370CASE ncol OF 36380WHEN 255 36390[OPT Z 36400.fs% 36410STMFD SP !,{R14} 36420LDR R1,[R9,#5*8]:LDR R1,[R1] 36430LDR R10,[R9,#4*8] 36440LDR R11,[R9,#3*8] 36450LDR R12,[R9,#2*8]:LDR R12,[R12] 36460LDR R8,[R9,#8]:LDR R8,[R8] 36470LDR R9,[R9]:LDR R9,[R9] 36480LDR R4,[R10],R8 36490.fsloop 36500TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 36510ADD R0,R4,#256:MOV R0,R0,LSR #bits-8 36520CMP R0,#256:MOVCS R0,#255:STRB R0,[R12],R1 36530MOV R2,R0,LSL #bits-8 36540] 36550IFdither% THEN 36560[OPT Z 36570SUB R4,R4,R2 36580MOVCS R4,#0 36590ADD R2,R4,R4,LSL #1 36600LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 36610STR R3,[R11,-R8] 36620ADD R2,R4,R4,LSL #2 36630LDR R3,[R11]:ADD R3,R3,R2,ASR #4 36640STR R3,[R11] 36650MOV R3,R4,ASR #4 36660STR R3,[R11,R8]! 36670RSB R2,R4,R4,LSL #3 36680LDR R4,[R10],R8 36690ADD R4,R4,R2,ASR #4 36700] 36710ELSE 36720[OPT Z 36730LDR R4,[R10],R8 36740] 36750ENDIF 36760[OPT Z 36770SUBS R9,R9,#1:BNE fsloop 36780LDMFD SP !,{PC}^ 36790] 36800WHEN 63 36810IFm$="P" THEN 36820[OPT Z 36830.div15 36840] 36850FORI%=0TO255 36860[OPT Z 36870EQUD (I%AND7 OR (I%AND16)>>1)/bright%*F 36880EQUD (I%AND3 OR (I%AND&60)>>3)/bright%*F 36890EQUD (I%AND3 OR (I%AND8)>>1 OR (I%AND128)>>4)/bright%*F 36900] 36910NEXT 36920[OPT Z 36930.colmatchloc EQUD lookup% 36940EQUD div15 36950] 36960ELSE 36970[OPT Z 36980.div15 EQUD 0 36990EQUD 4/bright%*F 37000EQUD 8/bright%*F 37010EQUD 12/bright%*F 37020] 37030ENDIF 37040[OPT Z 37050.fs% 37060STMFD SP !,{R14} 37070LDR R1,[R9,#5*8]:LDR R1,[R1] 37080LDR R10,[R9,#4*8] 37090LDR R11,[R9,#3*8] 37100LDR R12,[R9,#2*8]:LDR R12,[R12] 37110LDR R8,[R9,#8]:LDR R8,[R8] 37120LDR R9,[R9]:LDR R9,[R9] 37130LDR R4,[R10] 37140LDR R5,[R10,#4] 37150LDR R6,[R10,#8] 37160] 37170IFm$="P" THEN 37180[OPT Z 37190LDR R7,colmatchloc+4 37200] 37210ELSE 37220[OPT Z 37230ADR R7,div15 37240] 37250ENDIF 37260[OPT Z 37270.fsloop 37280ADD R10,R10,R8 37290] 37300IFm$="P" THEN 37310[OPT Z 37320TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 37330MOV R0,R4,LSR #(bits-4):CMP R0,#15:MOVCS R0,#15 37340TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 37350MOV R3,R5,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #4 37360TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 37370MOV R3,R6,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #8 37380LDR R3,colmatchloc 37390LDRB R0,[R3,R0] 37400ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 37410LDR R2,[R3],#4:SUB R4,R4,R2 37420LDMIA R3,{R2,R3}:SUB R5,R5,R2:SUB R6,R6,R3 37430] 37440ELSE 37450[OPT Z 37460TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 37470MOV R3,R4,LSR #bits-2 37480CMP R3,#4:MOVCS R3,#3 37490SUB R14,R4,R3,LSL #bits-2 37500LDR R2,[R7,R3,LSL #2] 37510SUB R4,R4,R2 37520AND R2,R3,#1:MOV R0,R2,LSL #2 37530AND R2,R3,#2:ORR R0,R0,R2,LSL #3 37540TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 37550MOV R3,R5,LSR #bits-2 37560CMP R3,#4:MOVCS R3,#3 37570SUB R2,R5,R3,LSL #bits-2 37580ADD R14,R14,R2 37590LDR R2,[R7,R3,LSL #2] 37600SUB R5,R5,R2 37610ORR R0,R0,R3,LSL #5 37620TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 37630MOV R3,R6,LSR #bits-2 37640CMP R3,#4:MOVCS R3,#3 37650SUB R2,R6,R3,LSL #bits-2 37660ADD R14,R14,R2 37670LDR R2,[R7,R3,LSL #2] 37680SUB R6,R6,R2 37690AND R2,R3,#1:ORR R0,R0,R2,LSL #3 37700AND R2,R3,#2:ORR R0,R0,R2,LSL #6 37710] 37720IFm$<>"T" THEN 37730[OPT Z 37740ADD R2,R14,R14,LSL #2 37750MOV R2,R2,LSR #bits 37760CMP R2,#3:MOVCS R2,#3 37770ORR R0,R0,R2 37780LDR R2,[R7,R2,LSL #2] 37790SUB R4,R4,R2,LSR #2 37800SUB R5,R5,R2,LSR #2 37810SUB R6,R6,R2,LSR #2 37820] 37830ENDIF 37840ENDIF 37850[OPT Z 37860STRB R0,[R12],R1 37870] 37880IFdither% THEN 37890[OPT Z 37900ADD R0,R11,#4 37910ADD R2,R4,R4,LSL #1 37920LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 37930STR R3,[R11,-R8] 37940ADD R2,R4,R4,LSL #2 37950LDR R3,[R11]:ADD R3,R3,R2,ASR #4 37960STR R3,[R11] 37970MOV R3,R4,ASR #4 37980STR R3,[R11,R8]! 37990RSB R2,R4,R4,LSL #3 38000LDR R4,[R10] 38010ADD R4,R4,R2,ASR #4 38020ADD R2,R5,R5,LSL #1 38030LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 38040STR R3,[R0,-R8] 38050MOV R3,R5,ASR #4 38060STR R3,[R0,R8] 38070ADD R2,R5,R5,LSL #2 38080LDR R3,[R0]:ADD R3,R3,R2,ASR #4 38090STR R3,[R0],#4 38100RSB R2,R5,R5,LSL #3 38110LDR R5,[R10,#4] 38120ADD R5,R5,R2,ASR #4 38130ADD R2,R6,R6,LSL #1 38140LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 38150STR R3,[R0,-R8] 38160ADD R2,R6,R6,LSL #2 38170LDR R3,[R0]:ADD R3,R3,R2,ASR #4 38180STR R3,[R0] 38190MOV R3,R6,ASR #4 38200STR R3,[R0,R8] 38210RSB R2,R6,R6,LSL #3 38220LDR R6,[R10,#8] 38230ADD R6,R6,R2,ASR #4 38240] 38250ELSE 38260[OPT Z 38270LDMIA R10,{R4,R5,R6} 38280] 38290ENDIF 38300[OPT Z 38310SUBS R9,R9,#1:BNE fsloop 38320LDMFD SP !,{PC}^ 38330] 38340WHEN 15 38350divtable=P%:CASE m$ OF 38360WHEN "D" 38370WHEN "P" 38380FORI%=0TO15*4STEP4 38390[OPT Z 38400EQUD (palette%!I%>>12AND&F)/bright%*F 38410EQUD (palette%!I%>>20AND&F)/bright%*F 38420EQUD (palette%!I%>>28AND&F)/bright%*F 38430] 38440NEXT 38450[OPT Z 38460.colmatchloc EQUD lookup% 38470] 38480WHEN "C" 38490FORI%=0TO3 38500[OPT Z 38510EQUD I%/(bright%DIV4)*F 38520] 38530NEXT 38540WHEN "T" 38550FORI%=0TO15 38560[OPT Z 38570EQUD I%/bright%*F 38580] 38590NEXT 38600WHEN "" 38610FORI%=0TO7 38620[OPT Z 38630EQUD I%/(bright%DIV2)*F 38640] 38650NEXT 38660ENDCASE 38670[OPT Z 38680.fs% 38690STMFD SP !,{R14} 38700LDR R1,[R9,#5*8]:LDR R1,[R1] 38710LDR R10,[R9,#4*8] 38720LDR R11,[R9,#3*8] 38730LDR R12,[R9,#2*8]:LDR R12,[R12] 38740LDR R8,[R9,#8]:LDR R8,[R8] 38750LDR R9,[R9]:LDR R9,[R9] 38760] 38770IFm$="C" OR m$="D" OR m$="P" THEN 38780[OPT Z 38790LDR R4,[R10] 38800LDR R5,[R10,#4] 38810LDR R6,[R10,#8] 38820] 38830ELSE 38840[OPT Z 38850LDR R4,[R10],R8 38860] 38870ENDIF 38880IFm$="C"ORm$="T"ORm$=""ORm$="P" THEN 38890[OPT Z 38900ADR R7,divtable 38910] 38920ENDIF 38930[OPT Z 38940.fsloop 38950] 38960CASE m$ OF 38970WHEN "P" 38980[OPT Z 38990ADD R10,R10,R8 39000TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 39010MOV R0,R4,LSR #(bits-4):CMP R0,#15:MOVCS R0,#15 39020TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 39030MOV R3,R5,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #4 39040TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 39050MOV R3,R6,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #8 39060LDR R3,colmatchloc 39070LDRB R0,[R3,R0] 39080ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 39090LDR R2,[R3],#4:SUB R4,R4,R2 39100LDMIA R3,{R2,R3}:SUB R5,R5,R2:SUB R6,R6,R3 39110MOV R3,R0 39120] 39130WHEN "D" 39140[OPT Z 39150ADD R10,R10,R8 39160MOV R3,#0 39170TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 39180CMP R4,#F>>1 39190SUBCS R4,R4,#F:ORRCS R3,R3,#1 39200TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 39210CMP R5,#F>>1 39220SUBCS R5,R5,#F:ORRCS R3,R3,#2 39230TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 39240CMP R6,#F>>1 39250SUBCS R6,R6,#F:ORRCS R3,R3,#4 39260] 39270WHEN "C" 39280[OPT Z 39290ADD R10,R10,R8 39300TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 39310MOV R3,R5,LSR #bits-2:CMP R3,#3:MOVCS R3,#3 39320LDR R2,[R7,R3,LSL #2] 39330SUB R5,R5,R2 39340TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 39350CMP R4,#F>>1 39360SUBCS R4,R4,#F:ORRCS R3,R3,#4 39370TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 39380CMP R6,#F>>1 39390SUBCS R6,R6,#F:ORRCS R3,R3,#8 39400] 39410WHEN "T" 39420[OPT Z 39430TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 39440MOV R3,R4,LSR #bits-4:CMP R3,#15:MOVCS R3,#15 39450LDR R2,[R7,R3,LSL #2] 39460SUB R4,R4,R2 39470] 39480WHEN "" 39490[OPT Z 39500TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 39510MOV R3,R4,LSR #bits-3:CMP R3,#7:MOVCS R3,#7 39520LDR R2,[R7,R3,LSL #2] 39530SUB R4,R4,R2 39540] 39550ENDCASE 39560[OPT Z 39570MOV R2,R12,LSR #1 39580TST R12,#1 39590LDRB R0,[R2] 39600ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 39610ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 39620STRB R0,[R2] 39630ADD R12,R12,R1 39640] 39650IFm$="C" OR m$="D" OR m$="P" THEN 39660IFdither% THEN 39670[OPT Z 39680ADD R0,R11,#4 39690ADD R2,R4,R4,LSL #1 39700LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 39710STR R3,[R11,-R8] 39720ADD R2,R4,R4,LSL #2 39730LDR R3,[R11]:ADD R3,R3,R2,ASR #4 39740STR R3,[R11] 39750MOV R3,R4,ASR #4 39760STR R3,[R11,R8]! 39770RSB R2,R4,R4,LSL #3 39780LDR R4,[R10] 39790ADD R4,R4,R2,ASR #4 39800ADD R2,R5,R5,LSL #1 39810LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 39820STR R3,[R0,-R8] 39830MOV R3,R5,ASR #4 39840STR R3,[R0,R8] 39850ADD R2,R5,R5,LSL #2 39860LDR R3,[R0]:ADD R3,R3,R2,ASR #4 39870STR R3,[R0],#4 39880RSB R2,R5,R5,LSL #3 39890LDR R5,[R10,#4] 39900ADD R5,R5,R2,ASR #4 39910ADD R2,R6,R6,LSL #1 39920LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 39930STR R3,[R0,-R8] 39940ADD R2,R6,R6,LSL #2 39950LDR R3,[R0]:ADD R3,R3,R2,ASR #4 39960STR R3,[R0] 39970MOV R3,R6,ASR #4 39980STR R3,[R0,R8] 39990RSB R2,R6,R6,LSL #3 40000LDR R6,[R10,#8] 40010ADD R6,R6,R2,ASR #4 40020] 40030ELSE 40040[OPT Z 40050LDMIA R10,{R4,R5,R6} 40060] 40070ENDIF 40080ELSE 40090IFdither% THEN 40100[OPT Z 40110ADD R2,R4,R4,LSL #1 40120LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 40130STR R3,[R11,-R8] 40140ADD R2,R4,R4,LSL #2 40150LDR R3,[R11]:ADD R3,R3,R2,ASR #4 40160STR R3,[R11] 40170MOV R3,R4,ASR #4 40180STR R3,[R11,R8]! 40190RSB R2,R4,R4,LSL #3 40200LDR R4,[R10],R8 40210ADD R4,R4,R2,ASR #4 40220] 40230ELSE 40240[OPT Z 40250LDR R4,[R10],R8 40260] 40270ENDIF 40280ENDIF 40290[OPT Z 40300SUBS R9,R9,#1:BNE fsloop 40310LDMFD SP !,{PC}^ 40320] 40330WHEN 3 40340IFm$<>"C" THEN 40350[OPT Z 40360.div3 EQUD 0 40370EQUD 1/(bright%DIV4)*F 40380EQUD 2/(bright%DIV4)*F 40390EQUD F 40400] 40410ENDIF 40420[OPT Z 40430.fs% 40440STMFD SP !,{R14} 40450LDR R1,[R9,#5*8]:LDR R1,[R1] 40460LDR R10,[R9,#4*8] 40470LDR R11,[R9,#3*8] 40480LDR R12,[R9,#2*8] 40490LDR R12,[R12] 40500LDR R8,[R9,#8] 40510LDR R8,[R8] 40520LDR R9,[R9] 40530LDR R9,[R9] 40540] 40550IFm$="C" THEN 40560[OPT Z 40570LDR R4,[R10] 40580LDR R5,[R10,#4] 40590LDR R6,[R10,#8] 40600] 40610ELSE 40620[OPT Z 40630LDR R4,[R10],R8 40640ADR R7,div3 40650] 40660ENDIF 40670[OPT Z 40680.fsloop 40690] 40700IFm$="C" THEN 40710[OPT Z 40720ADD R10,R10,R8 40730TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 40740TEQ R5,#0:MOVMI R5,#0:CMP R5,#F:MOVCS R5,#F 40750TEQ R6,#0:MOVMI R6,#0:CMP R6,#F:MOVCS R6,#F 40760MOV R3,#0 40770CMP R4,#F>>1:ORRCS R3,R3,#1 40780CMP R5,#F>>1:ORRCS R3,R3,#2 40790CMP R6,#F>>1:ORRCS R3,R3,#4 40800CMP R3,#6:MOVEQ R3,#1:BEQ octcyan 40810BCS octwhite 40820CMP R3,#4:BEQ octblue 40830MOVCS R3,#2:BCS octmagenta 40840CMP R3,#2:BEQ octgreen 40850BCS octyellow 40860CMP R3,#0:BEQ octblack 40870.octred 40880RSB R0,R4,#F 40890CMP R5,R0 40900BLT octred1 40910CMP R5,R6 40920MOVGE R3,#3 40930MOVLT R3,#2 40940B octconvert 40950.octred1 40960CMP R0,R6 40970MOVGE R3,#0 40980MOVLT R3,#2 40990B octconvert 41000.octgreen 41010RSB R0,R5,#F 41020CMP R0,R4 41030BLT octgreen1 41040CMP R0,R6 41050MOVGE R3,#0 41060MOVLT R3,#1 41070B octconvert 41080.octgreen1 41090CMP R4,R6 41100MOVGE R3,#3 41110MOVLT R3,#1 41120B octconvert 41130.octblue 41140RSB R0,R6,#F 41150CMP R0,R4 41160BLT octblue1 41170CMP R0,R5 41180MOVGE R3,#0 41190MOVLT R3,#1 41200B octconvert 41210.octblue1 41220CMP R4,R5 41230MOVGE R3,#2 41240MOVLT R3,#1 41250B octconvert 41260.octwhite 41270CMP R4,R5 41280BLT octwhite1 41290CMP R5,R6 41300MOVGE R3,#3 41310MOVLT R3,#2 41320B octconvert 41330.octwhite1 41340CMP R4,R6 41350MOVGE R3,#3 41360MOVLT R3,#1 41370.octconvert 41380CMP R3,#1 41390.octcyan 41400SUBEQ R5,R5,#F 41410SUBEQ R6,R6,#F 41420.octmagenta 41430CMP R3,#2 41440SUBEQ R4,R4,#F 41450SUBEQ R6,R6,#F 41460.octyellow 41470CMP R3,#3 41480SUBEQ R4,R4,#F 41490SUBEQ R5,R5,#F 41500.octblack 41510MOV R2,R12,LSR #2 41520AND R7,R12,#3:MOV R7,R7,LSL #1 41530MOV R14,#3 41540MOV R14,R14,LSL R7 41550LDRB R0,[R2]:BIC R0,R0,R14:ORR R0,R0,R3,LSL R7:STRB R0,[R2] 41560ADD R12,R12,R1 41570] 41580IFdither% THEN 41590[OPT Z 41600ADD R0,R11,#4 41610ADD R2,R4,R4,LSL #1 41620LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 41630STR R3,[R11,-R8] 41640ADD R2,R4,R4,LSL #2 41650LDR R3,[R11]:ADD R3,R3,R2,ASR #4 41660STR R3,[R11] 41670MOV R3,R4,ASR #4 41680STR R3,[R11,R8]! 41690RSB R2,R4,R4,LSL #3 41700LDR R4,[R10] 41710ADD R4,R4,R2,ASR #4 41720ADD R2,R5,R5,LSL #1 41730LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 41740STR R3,[R0,-R8] 41750MOV R3,R5,ASR #4 41760STR R3,[R0,R8] 41770ADD R2,R5,R5,LSL #2 41780LDR R3,[R0]:ADD R3,R3,R2,ASR #4 41790STR R3,[R0],#4 41800RSB R2,R5,R5,LSL #3 41810LDR R5,[R10,#4] 41820ADD R5,R5,R2,ASR #4 41830ADD R2,R6,R6,LSL #1 41840LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 41850STR R3,[R0,-R8] 41860ADD R2,R6,R6,LSL #2 41870LDR R3,[R0]:ADD R3,R3,R2,ASR #4 41880STR R3,[R0] 41890MOV R3,R6,ASR #4 41900STR R3,[R0,R8] 41910RSB R2,R6,R6,LSL #3 41920LDR R6,[R10,#8] 41930ADD R6,R6,R2,ASR #4 41940] 41950ELSE 41960[OPT Z 41970LDMIA R10,{R4,R5,R6} 41980] 41990ENDIF 42000ELSE 42010[OPT Z 42020TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 42030MOV R3,R4,LSR #bits-2:CMP R3,#3:MOVCS R3,#3 42040LDR R2,[R7,R3,LSL #2] 42050SUB R4,R4,R2 42060MOV R2,R12,LSR #2 42070AND R5,R12,#3:MOV R5,R5,LSL #1 42080MOV R6,#3:MOV R6,R6,LSL R5 42090LDRB R0,[R2]:BIC R0,R0,R6:ORR R0,R0,R3,LSL R5:STRB R0,[R2] 42100ADD R12,R12,R1 42110] 42120IFdither% THEN 42130[OPT Z 42140ADD R2,R4,R4,LSL #1 42150LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 42160STR R3,[R11,-R8] 42170ADD R2,R4,R4,LSL #2 42180LDR R3,[R11]:ADD R3,R3,R2,ASR #4 42190STR R3,[R11] 42200MOV R3,R4,ASR #4 42210STR R3,[R11,R8]! 42220RSB R2,R4,R4,LSL #3 42230LDR R4,[R10],R8 42240ADD R4,R4,R2,ASR #4 42250] 42260ELSE 42270[OPT Z 42280LDR R4,[R10],R8 42290] 42300ENDIF 42310ENDIF 42320[OPT Z 42330SUBS R9,R9,#1:BNE fsloop 42340LDMFD SP !,{PC}^ 42350] 42360WHEN 1 42370CASE m$ OF 42380WHEN"C" 42390[OPT Z 42400.divtable EQUD 0 42410EQUD (1-black%/256*2)/16*F 42420EQUD (2-black%/256*4)/16*F 42430EQUD (3-black%/256*5)/16*F 42440EQUD (4-black%/256*6)/16*F 42450EQUD (5-black%/256*7)/16*F 42460EQUD (6-black%/256*8)/16*F 42470EQUD (7-black%/256*8)/16*F 42480EQUD (8-black%/256*8)/16*F 42490EQUD (9-black%/256*8)/16*F 42500EQUD (10-black%/256*8)/16*F 42510EQUD (11-black%/256*7)/16*F 42520EQUD (12-black%/256*6)/16*F 42530EQUD (13-black%/256*5)/16*F 42540EQUD (14-black%/256*4)/16*F 42550EQUD (15-black%/256*2)/16*F 42560EQUD F 42570.evenrow_gard DCD even_gard 42580.oddrow_gard DCD odd_gard 42590.rowinc DCD 0 42600.fs% 42610STMFD SP !,{R14} 42620LDR R1,[R9,#5*8]:LDR R1,[R1] 42630LDR R10,[R9,#4*8] 42640LDR R11,[R9,#3*8] 42650LDR R12,[R9,#2*8] 42660LDR R12,[R12] 42670LDR R8,[R9,#8] 42680LDR R8,[R8] 42690LDR R9,[R9] 42700LDR R9,[R9] 42710LDR R4,[R10],R8 42720TEQ R8,#0 42730LDRPL R6,evenrow_gard 42740LDRMI R6,oddrow_gard 42750MOV R1,R1,LSL #1 42760LDR R7,rowinc 42770ADR R14,divtable 42780.fsloop 42790TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 42800ADD R5,R4,#F>>5 42810MOVS R5,R5,LSR #bits-4 42820LDRNE R0,[R14,R5,LSL #2] 42830SUBNE R4,R4,R0 42840] 42850IFdither% THEN 42860[OPT Z 42870ADD R2,R4,R4,LSL #1 42880LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 42890STR R3,[R11,-R8] 42900ADD R2,R4,R4,LSL #2 42910LDR R3,[R11]:ADD R3,R3,R2,ASR #4 42920STR R3,[R11] 42930MOV R3,R4,ASR #4 42940STR R3,[R11,R8]! 42950RSB R2,R4,R4,LSL #3 42960LDR R4,[R10],R8 42970ADDS R4,R4,R2,ASR #4 42980] 42990ELSE 43000[OPT Z 43010LDR R4,[R10],R8 43020] 43030ENDIF 43040[OPT Z 43050MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 43060ADD R3,R4,#F>>5 43070MOVS R3,R3,LSR #bits-4 43080LDRNE R0,[R14,R3,LSL #2] 43090SUBNE R4,R4,R0 43100ORR R5,R5,R3,LSL #5:LDR R3,[R6,R5,LSL #2] 43110MOV R2,R12,LSR #1:STRB R3,[R2],R7:MOV R3,R3,LSR #8:STRB R3,[R2],R7 43120MOV R3,R3,LSR #8:STRB R3,[R2],R7:MOV R3,R3,LSR #8:STRB R3,[R2] 43130ADD R12,R12,R1 43140] 43150IFdither% THEN 43160[OPT Z 43170ADD R2,R4,R4,LSL #1 43180LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 43190STR R3,[R11,-R8] 43200ADD R2,R4,R4,LSL #2 43210LDR R3,[R11]:ADD R3,R3,R2,ASR #4 43220STR R3,[R11] 43230MOV R3,R4,ASR #4 43240STR R3,[R11,R8]! 43250RSB R2,R4,R4,LSL #3 43260LDR R4,[R10],R8 43270ADD R4,R4,R2,ASR #4 43280] 43290ELSE 43300[OPT Z 43310LDR R4,[R10],R8 43320] 43330ENDIF 43340[OPT Z 43350SUBS R9,R9,#2:BNE fsloop 43360LDMFD SP !,{PC}^ 43370] 43380WHEN"T" 43390[OPT Z 43400.divtable EQUD 0 43410EQUD (1-black%/256*2)/9*F 43420EQUD (2-black%/256*4)/9*F 43430EQUD (3-black%/256*5)/9*F 43440EQUD (4-black%/256*6)/9*F 43450EQUD (5-black%/256*6)/9*F 43460EQUD (6-black%/256*5)/9*F 43470EQUD (7-black%/256*4)/9*F 43480EQUD (8-black%/256*2)/9*F 43490EQUD F 43500.evenrow_gard DCD even_gard 43510.oddrow_gard DCD odd_gard 43520.rowinc DCD 0 43530.fs% 43540STMFD SP !,{R14} 43550LDR R1,[R9,#5*8]:LDR R1,[R1] 43560LDR R10,[R9,#4*8] 43570LDR R11,[R9,#3*8] 43580LDR R12,[R9,#2*8] 43590LDR R12,[R12] 43600LDR R8,[R9,#8] 43610LDR R8,[R8] 43620LDR R9,[R9] 43630LDR R9,[R9] 43640LDR R4,[R10],R8 43650TEQ R8,#0 43660LDRPL R6,evenrow_gard 43670LDRMI R6,oddrow_gard 43680MOV R1,R1,LSL #1 43690LDR R7,rowinc 43700ADR R14,divtable 43710.fsloop 43720TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 43730ADD R5,R4,#F>>4 43740ADD R5,R5,R5,LSL #3 43750MOVS R5,R5,LSR #bits 43760LDRNE R0,[R14,R5,LSL #2] 43770SUBNE R4,R4,R0 43780] 43790IFdither% THEN 43800[OPT Z 43810ADD R2,R4,R4,LSL #1 43820LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 43830STR R3,[R11,-R8] 43840ADD R2,R4,R4,LSL #2 43850LDR R3,[R11]:ADD R3,R3,R2,ASR #4 43860STR R3,[R11] 43870MOV R3,R4,ASR #4 43880STR R3,[R11,R8]! 43890RSB R2,R4,R4,LSL #3 43900LDR R4,[R10],R8 43910ADDS R4,R4,R2,ASR #4 43920] 43930ELSE 43940[OPT Z 43950LDR R4,[R10],R8 43960] 43970ENDIF 43980[OPT Z 43990MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 44000ADD R3,R4,#F>>4 44010ADD R3,R3,R3,LSL #3 44020MOVS R3,R3,LSR #bits 44030LDRNE R0,[R14,R3,LSL #2] 44040SUBNE R4,R4,R0 44050ORR R5,R5,R3,LSL #4:LDR R5,[R6,R5,LSL #2] 44060MOV R2,R12,LSR #1 44070AND R3,R5,#&3F 44080STRB R3,[R2],R7 44090MOV R3,R5,LSR #6:AND R3,R3,#&3F 44100STRB R3,[R2],R7 44110MOV R3,R5,LSR #12:STRB R3,[R2] 44120ADD R12,R12,R1 44130] 44140IFdither% THEN 44150[OPT Z 44160ADD R2,R4,R4,LSL #1 44170LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 44180STR R3,[R11,-R8] 44190ADD R2,R4,R4,LSL #2 44200LDR R3,[R11]:ADD R3,R3,R2,ASR #4 44210STR R3,[R11] 44220MOV R3,R4,ASR #4 44230STR R3,[R11,R8]! 44240RSB R2,R4,R4,LSL #3 44250LDR R4,[R10],R8 44260ADD R4,R4,R2,ASR #4 44270] 44280ELSE 44290[OPT Z 44300LDR R4,[R10],R8 44310] 44320ENDIF 44330[OPT Z 44340SUBS R9,R9,#2:BNE fsloop 44350LDMFD SP !,{PC}^ 44360] 44370WHEN"D" 44380[OPT Z 44390.divtable EQUD 0 44400EQUD (1-black%/256*2)/4*F 44410EQUD (2-black%/256*4)/4*F 44420EQUD (3-black%/256*2)/4*F 44430EQUD F 44440.evenrow_gard DCD even_gard 44450.oddrow_gard DCD odd_gard 44460.rowinc DCD 0 44470.fs% 44480STMFD SP !,{R14} 44490LDR R1,[R9,#5*8]:LDR R1,[R1] 44500LDR R10,[R9,#4*8] 44510LDR R11,[R9,#3*8] 44520LDR R12,[R9,#2*8] 44530LDR R12,[R12] 44540LDR R8,[R9,#8] 44550LDR R8,[R8] 44560LDR R9,[R9] 44570LDR R9,[R9] 44580LDR R4,[R10],R8 44590TEQ R8,#0 44600LDRPL R6,evenrow_gard 44610LDRMI R6,oddrow_gard 44620MOV R1,R1,LSL #1 44630LDR R7,rowinc 44640ADR R14,divtable 44650.fsloop 44660TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 44670ADD R5,R4,#F>>3 44680MOVS R5,R5,LSR #bits-2 44690LDRNE R0,[R14,R5,LSL #2] 44700SUBNE R4,R4,R0 44710] 44720IFdither% THEN 44730[OPT Z 44740ADD R2,R4,R4,LSL #1 44750LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 44760STR R3,[R11,-R8] 44770ADD R2,R4,R4,LSL #2 44780LDR R3,[R11]:ADD R3,R3,R2,ASR #4 44790STR R3,[R11] 44800MOV R3,R4,ASR #4 44810STR R3,[R11,R8]! 44820RSB R2,R4,R4,LSL #3 44830LDR R4,[R10],R8 44840ADDS R4,R4,R2,ASR #4 44850] 44860ELSE 44870[OPT Z 44880LDR R4,[R10],R8 44890] 44900ENDIF 44910[OPT Z 44920MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 44930ADD R3,R4,#F>>3 44940MOVS R3,R3,LSR #bits-2 44950LDRNE R0,[R14,R3,LSL #2] 44960SUBNE R4,R4,R0 44970ORR R5,R5,R3,LSL #3:LDRB R5,[R6,R5] 44980MOV R2,R12,LSR #2 44990TST R12,#2 45000AND R3,R5,#&F:LDRB R0,[R2] 45010ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 45020ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 45030STRB R0,[R2],R7 45040MOV R3,R5,LSR #4:LDRB R0,[R2] 45050ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 45060ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 45070STRB R0,[R2] 45080ADD R12,R12,R1 45090] 45100IFdither% THEN 45110[OPT Z 45120ADD R2,R4,R4,LSL #1 45130LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 45140STR R3,[R11,-R8] 45150ADD R2,R4,R4,LSL #2 45160LDR R3,[R11]:ADD R3,R3,R2,ASR #4 45170STR R3,[R11] 45180MOV R3,R4,ASR #4 45190STR R3,[R11,R8]! 45200RSB R2,R4,R4,LSL #3 45210LDR R4,[R10],R8 45220ADD R4,R4,R2,ASR #4 45230] 45240ELSE 45250[OPT Z 45260LDR R4,[R10],R8 45270] 45280ENDIF 45290[OPT Z 45300SUBS R9,R9,#2:BNE fsloop 45310LDMFD SP !,{PC}^ 45320] 45330OTHERWISE 45340[OPT Z 45350.fs% 45360STMFD SP !,{R14} 45370LDR R1,[R9,#5*8]:LDR R1,[R1] 45380LDR R10,[R9,#4*8] 45390LDR R11,[R9,#3*8] 45400LDR R12,[R9,#2*8] 45410LDR R12,[R12] 45420LDR R8,[R9,#8] 45430LDR R8,[R8] 45440LDR R9,[R9] 45450LDR R9,[R9] 45460LDR R4,[R10],R8 45470MOV R7,#1 45480.fsloop 45490TEQ R4,#0:MOVMI R4,#0:CMP R4,#F:MOVCS R4,#F 45500] 45510IFblack% THEN 45520[OPT Z 45530MOV R2,R12,LSR #3 45540AND R5,R12,#7:MOV R6,#1:MOV R6,R6,LSL R5 45550LDRB R0,[R2,#-(x%+7>>3)] 45560SUB R3,R4,#F 45570CMP R7,#0 45580ADDNE R4,R4,#black%<<(bits-8) 45590ADDEQ R3,R3,#black%<<(bits-8) 45600TST R0,R6 45610ADDNE R4,R4,#black%<<(bits-8) 45620ADDEQ R3,R3,#black%<<(bits-8) 45630MOVS R0,R3:RSBMI R0,R3,#0 45640CMP R4,R0 45650MOVCC R3,#0 45660MOVCS R4,R3:MOVCS R3,#1 45670MOV R7,R3 45680] 45690ELSE 45700[OPT Z 45710ADD R3,R4,#F>>1:MOV R3,R3,LSR #bits 45720SUB R4,R4,R3,LSL #bits 45730MOV R2,R12,LSR #3 45740AND R5,R12,#7:MOV R6,#1:MOV R6,R6,LSL R5 45750] 45760ENDIF 45770[OPT Z 45780LDRB R0,[R2]:BIC R0,R0,R6:ORR R0,R0,R3,LSL R5 45790STRB R0,[R2] 45800ADD R12,R12,R1 45810] 45820IFdither% THEN 45830[OPT Z 45840ADD R2,R4,R4,LSL #1 45850LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 45860STR R3,[R11,-R8] 45870ADD R2,R4,R4,LSL #2 45880LDR R3,[R11]:ADD R3,R3,R2,ASR #4 45890STR R3,[R11] 45900MOV R3,R4,ASR #4 45910STR R3,[R11,R8]! 45920RSB R2,R4,R4,LSL #3 45930LDR R4,[R10],R8 45940ADD R4,R4,R2,ASR #4 45950] 45960ELSE 45970[OPT Z 45980LDR R4,[R10],R8 45990] 46000ENDIF 46010[OPT Z 46020SUBS R9,R9,#1:BNE fsloop 46030LDMFD SP !,{PC}^ 46040] 46050ENDCASE 46060ENDCASE 46070[OPT Z 46080.sxloc DCD sx% 46090] 46100CASE col OF 46110WHEN 0 46120IFinput<=8 THEN 46130[OPT Z 46140.mappix% 46150LDR R0,sxloc 46160LDR R1,[R9]:LDR R1,[R1] 46170LDR R2,[R9,#3*8] 46180LDR R5,[R9,#4*8] 46190.mappixlp 46200LDRB R6,[R1],#step24 46210] 46220ENDIF 46230CASE input OF 46240WHEN 8 46250[OPT Z 46260LDR R7,[R2,R6,LSL #2]:STR R7,[R5],#4 46270SUBS R0,R0,#1:BNE mappixlp 46280MOVS PC,R14 46290] 46300WHEN 4 46310IFbigendianbits THEN 46320[OPT Z 46330MOV R10,R6,LSR #4 46340LDR R7,[R2,R10,LSL #2] 46350AND R10,R6,#&F 46360] 46370ELSE 46380[OPT Z 46390AND R10,R6,#&F 46400LDR R7,[R2,R10,LSL #2] 46410MOV R10,R6,LSR #4 46420] 46430ENDIF 46440[OPT Z 46450LDR R8,[R2,R10,LSL #2]:STMIA R5!,{R7,R8} 46460SUBS R0,R0,#2:BHI mappixlp 46470MOVS PC,R14 46480] 46490WHEN 2 46500IFbigendianbits THEN 46510[OPT Z 46520MOV R10,R6,LSR #6 46530LDR R7,[R2,R10,LSL #2] 46540AND R10,R6,#&30 46550LDR R8,[R2,R10,LSR #2] 46560AND R10,R6,#&C 46570LDR R9,[R2,R10] 46580AND R10,R6,#&3 46590] 46600ELSE 46610[OPT Z 46620AND R10,R6,#&3 46630LDR R7,[R2,R10,LSL #2] 46640AND R10,R6,#&C 46650LDR R8,[R2,R10] 46660AND R10,R6,#&30 46670LDR R9,[R2,R10,LSR #2] 46680MOV R10,R6,LSR #6 46690] 46700ENDIF 46710[OPT Z 46720LDR R10,[R2,R10,LSL #2]:STMIA R5!,{R7,R8,R9,R10} 46730SUBS R0,R0,#4:BHI mappixlp 46740MOVS PC,R14 46750] 46760WHEN 1 46770IFbigendianbits THEN 46780[OPT Z 46790AND R10,R6,#&80 46800LDR R7,[R2,R10,LSR #5] 46810AND R10,R6,#&40 46820LDR R8,[R2,R10,LSR #4] 46830AND R10,R6,#&20 46840LDR R9,[R2,R10,LSR #3] 46850AND R10,R6,#&10 46860LDR R10,[R2,R10,LSR #2]:STMIA R5!,{R7,R8,R9,R10} 46870AND R10,R6,#&8 46880LDR R7,[R2,R10,LSR #1] 46890AND R10,R6,#&4 46900LDR R8,[R2,R10] 46910AND R10,R6,#&2 46920LDR R9,[R2,R10,LSL #1] 46930AND R10,R6,#&1 46940] 46950ELSE 46960[OPT Z 46970AND R10,R6,#&1 46980LDR R7,[R2,R10,LSL #2] 46990AND R10,R6,#&2 47000LDR R8,[R2,R10,LSL #1] 47010AND R10,R6,#&4 47020LDR R9,[R2,R10] 47030AND R10,R6,#&8 47040LDR R10,[R2,R10,LSR #1]:STMIA R5!,{R7,R8,R9,R10} 47050AND R10,R6,#&10 47060LDR R7,[R2,R10,LSR #2] 47070AND R10,R6,#&20 47080LDR R8,[R2,R10,LSR #3] 47090AND R10,R6,#&40 47100LDR R9,[R2,R10,LSR #4] 47110MOV R10,R6,LSR #7 47120] 47130ENDIF 47140[OPT Z 47150LDR R10,[R2,R10,LSL #2]:STMIA R5!,{R7,R8,R9,R10} 47160SUBS R0,R0,#8:BHI mappixlp 47170MOVS PC,R14 47180] 47190WHEN 16 47200[OPT Z 47210.mappix% 47220LDR R0,sxloc 47230LDR R1,[R9]:LDR R1,[R1] 47240LDR R2,[R9,#8]:LDR R2,[R2] 47250LDR R3,[R9,#4*8] 47260LDR R4,[R9,#3*8] 47270LDR R5,[R9,#2*8] 47280LDR R6,[R9,#5*8] 47290LDR R7,[R9,#6*8] 47300LDR R8,[R9,#7*8] 47310CMP R1,R2 47320ADDEQ R2,R2,#1 47330.mappixlp 47340LDRB R9,[R1],#step24:LDRB R10,[R2],#step24 47350LDR R9,[R6,R9,LSL #2]:LDR R10,[R7,R10,LSL #2]:ORR R9,R9,R10 47360AND R10,R9,#255:LDR R10,[R3,R10,LSL #2] 47370MOV R11,R9,LSR #8:AND R11,R11,#255:LDR R11,[R4,R11,LSL #2] 47380MOV R12,R9,LSR #16:LDR R12,[R5,R12,LSL #2] 47390ADD R10,R10,R11:ADD R10,R10,R12:STMIA R8!,{R10} 47400SUBS R0,R0,#1:BNE mappixlp 47410MOVS PC,R14 47420] 47430WHEN 24 47440[OPT Z 47450.mappix% 47460LDR R0,sxloc 47470LDR R1,[R9,#2*8]:LDR R1,[R1] 47480LDR R2,[R9,#8]:LDR R2,[R2] 47490LDR R3,[R9]:LDR R3,[R3] 47500LDR R4,[R9,#5*8] 47510LDR R5,[R9,#4*8] 47520LDR R6,[R9,#3*8] 47530LDR R7,[R9,#6*8] 47540.mappixlp 47550LDRB R8,[R1],#step24:LDR R8,[R4,R8,LSL #2] 47560LDRB R9,[R2],#step24:LDR R9,[R5,R9,LSL #2]:ADD R8,R8,R9 47570LDRB R9,[R3],#step24:LDR R9,[R6,R9,LSL #2]:ADD R8,R8,R9:STR R8,[R7],#4 47580SUBS R0,R0,#1:BNE mappixlp 47590MOVS PC,R14 47600] 47610WHEN 422 47620[OPT Z 47630.mappix% 47640LDR R0,sxloc 47650LDR R1,[R9]:LDR R1,[R1] 47660ADD R1,R1,#1 47670LDR R4,[R9,#1*8] 47680LDR R7,[R9,#8*8] 47690.mappixlp 47700LDRB R8,[R1],#2 47710LDR R8,[R4,R8,LSL #2]:CMP R8,#F:MOVCS R8,#F:STR R8,[R7],#4 47720SUBS R0,R0,#1:BNE mappixlp 47730MOVS PC,R14 47740] 47750ENDCASE 47760[OPT Z 47770.xsample% 47780LDR R0,[R9]:LDR R0,[R0] 47790LDR R1,[R9,#8] 47800LDR R2,[R9,#2*8] 47810LDR R3,[R9,#3*8]:LDR R3,[R3] 47820LDR R4,[R9,#4*8]:LDR R4,[R4] 47830MOV R11,R4 47840.xsamplelp 47850LDMIA R1,{R5} 47860SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#4 47870SUBS R12,R3,#1 47880BEQ xdonediv 47890.xdivlp 47900CMP R12,R11 47910BCC xdivlp2 47920LDMIA R1!,{R8}:MLA R5,R8,R11,R5 47930SUBS R12,R12,R11:MOV R11,R4 47940BNE xdivlp 47950B xdonediv 47960.xdivlp2 47970LDMIA R1,{R8} 47980SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#4 47990ADD R5,R5,R8 48000SUBS R12,R12,#1:BNE xdivlp 48010.xdonediv 48020STMIA R2!,{R5} 48030SUBS R0,R0,#1:BPL xsamplelp 48040MOVS PC,R14 48050] 48060WHEN 2 48070IFinput<=8 THEN 48080[OPT Z 48090.mappix% 48100LDR R0,sxloc 48110LDR R1,[R9]:LDR R1,[R1] 48120LDR R2,[R9,#3*8] 48130LDR R3,[R9,#2*8] 48140LDR R4,[R9,#8] 48150LDR R5,[R9,#4*8] 48160.mappixlp 48170LDRB R6,[R1],#step24 48180] 48190ENDIF 48200CASE input OF 48210WHEN 8 48220IFham THEN 48230[OPT Z 48240ADR R9,ltable 48250MOVS R7,R6,LSR #4:AND R6,R6,#15 48260LDREQ R10,[R2,R6,LSL #2]:LDREQ R11,[R3,R6,LSL #2]:LDREQ R12,[R4,R6,LSL #2] 48270CMP R7,#1:LDREQ R12,[R9,R6,LSL #2] 48280CMP R7,#2:LDREQ R10,[R9,R6,LSL #2] 48290CMP R7,#3:LDREQ R11,[R9,R6,LSL #2] 48300STMIA R5!,{R10,R11,R12} 48310SUBS R0,R0,#1:BNE mappixlp 48320MOVS PC,R14 48330.ltable 48340] 48350FORI%=0TO15 48360[OPT Z 48370EQUD I%/15*F 48380] 48390NEXT 48400ELSE 48410[OPT Z 48420LDR R7,[R2,R6,LSL #2]:LDR R8,[R3,R6,LSL #2]:LDR R9,[R4,R6,LSL #2] 48430STMIA R5!,{R7,R8,R9} 48440SUBS R0,R0,#1:BNE mappixlp 48450MOVS PC,R14 48460] 48470ENDIF 48480WHEN 4 48490IFbigendianbits THEN 48500[OPT Z 48510MOV R10,R6,LSR #4 48520LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 48530STMIA R5!,{R7,R8,R9} 48540AND R10,R6,#&F 48550] 48560ELSE 48570[OPT Z 48580AND R10,R6,#&F 48590LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 48600STMIA R5!,{R7,R8,R9} 48610MOV R10,R6,LSR #4 48620] 48630ENDIF 48640[OPT Z 48650LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 48660STMIA R5!,{R7,R8,R9} 48670SUBS R0,R0,#2:BHI mappixlp 48680MOVS PC,R14 48690] 48700WHEN 2 48710IFbigendianbits THEN 48720[OPT Z 48730MOV R10,R6,LSR #6 48740LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 48750STMIA R5!,{R7,R8,R9} 48760AND R10,R6,#&30 48770LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 48780STMIA R5!,{R7,R8,R9} 48790AND R10,R6,#&C 48800LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 48810STMIA R5!,{R7,R8,R9} 48820AND R10,R6,#&3 48830] 48840ELSE 48850[OPT Z 48860AND R10,R6,#&3 48870LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 48880STMIA R5!,{R7,R8,R9} 48890AND R10,R6,#&C 48900LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 48910STMIA R5!,{R7,R8,R9} 48920AND R10,R6,#&30 48930LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 48940STMIA R5!,{R7,R8,R9} 48950MOV R10,R6,LSR #6 48960] 48970ENDIF 48980[OPT Z 48990LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 49000STMIA R5!,{R7,R8,R9} 49010SUBS R0,R0,#4:BHI mappixlp 49020MOVS PC,R14 49030] 49040WHEN 1 49050IFbigendianbits THEN 49060[OPT Z 49070AND R10,R6,#&80 49080LDR R7,[R2,R10,LSR #5]:LDR R8,[R3,R10,LSR #5]:LDR R9,[R4,R10,LSR #5] 49090STMIA R5!,{R7,R8,R9} 49100AND R10,R6,#&40 49110LDR R7,[R2,R10,LSR #4]:LDR R8,[R3,R10,LSR #4]:LDR R9,[R4,R10,LSR #4] 49120STMIA R5!,{R7,R8,R9} 49130AND R10,R6,#&20 49140LDR R7,[R2,R10,LSR #3]:LDR R8,[R3,R10,LSR #3]:LDR R9,[R4,R10,LSR #3] 49150STMIA R5!,{R7,R8,R9} 49160AND R10,R6,#&10 49170LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 49180STMIA R5!,{R7,R8,R9} 49190AND R10,R6,#&8 49200LDR R7,[R2,R10,LSR #1]:LDR R8,[R3,R10,LSR #1]:LDR R9,[R4,R10,LSR #1] 49210STMIA R5!,{R7,R8,R9} 49220AND R10,R6,#&4 49230LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 49240STMIA R5!,{R7,R8,R9} 49250AND R10,R6,#&2 49260LDR R7,[R2,R10,LSL #1]:LDR R8,[R3,R10,LSL #1]:LDR R9,[R4,R10,LSL #1] 49270STMIA R5!,{R7,R8,R9} 49280AND R10,R6,#&1 49290] 49300ELSE 49310[OPT Z 49320AND R10,R6,#&1 49330LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 49340STMIA R5!,{R7,R8,R9} 49350AND R10,R6,#&2 49360LDR R7,[R2,R10,LSL #1]:LDR R8,[R3,R10,LSL #1]:LDR R9,[R4,R10,LSL #1] 49370STMIA R5!,{R7,R8,R9} 49380AND R10,R6,#&4 49390LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 49400STMIA R5!,{R7,R8,R9} 49410AND R10,R6,#&8 49420LDR R7,[R2,R10,LSR #1]:LDR R8,[R3,R10,LSR #1]:LDR R9,[R4,R10,LSR #1] 49430STMIA R5!,{R7,R8,R9} 49440AND R10,R6,#&10 49450LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 49460STMIA R5!,{R7,R8,R9} 49470AND R10,R6,#&20 49480LDR R7,[R2,R10,LSR #3]:LDR R8,[R3,R10,LSR #3]:LDR R9,[R4,R10,LSR #3] 49490STMIA R5!,{R7,R8,R9} 49500AND R10,R6,#&40 49510LDR R7,[R2,R10,LSR #4]:LDR R8,[R3,R10,LSR #4]:LDR R9,[R4,R10,LSR #4] 49520STMIA R5!,{R7,R8,R9} 49530MOV R10,R6,LSR #7 49540] 49550ENDIF 49560[OPT Z 49570LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 49580STMIA R5!,{R7,R8,R9} 49590SUBS R0,R0,#8:BHI mappixlp 49600MOVS PC,R14 49610] 49620WHEN 16 49630[OPT Z 49640.mappix% 49650LDR R0,sxloc 49660LDR R1,[R9]:LDR R1,[R1] 49670LDR R2,[R9,#8]:LDR R2,[R2] 49680LDR R3,[R9,#4*8] 49690LDR R4,[R9,#3*8] 49700LDR R5,[R9,#2*8] 49710LDR R6,[R9,#5*8] 49720LDR R7,[R9,#6*8] 49730LDR R8,[R9,#7*8] 49740CMP R1,R2 49750ADDEQ R2,R2,#1 49760.mappixlp 49770LDRB R9,[R1],#step24:LDRB R10,[R2],#step24 49780LDR R9,[R6,R9,LSL #2]:LDR R10,[R7,R10,LSL #2]:ORR R9,R9,R10 49790AND R10,R9,#255:LDR R10,[R3,R10,LSL #2] 49800MOV R11,R9,LSR #8:AND R11,R11,#255:LDR R11,[R4,R11,LSL #2] 49810MOV R12,R9,LSR #16:LDR R12,[R5,R12,LSL #2] 49820STMIA R8!,{R10,R11,R12} 49830SUBS R0,R0,#1:BNE mappixlp 49840MOVS PC,R14 49850] 49860WHEN 24 49870[OPT Z 49880.mappix% 49890LDR R0,sxloc 49900LDR R1,[R9,#2*8]:LDR R1,[R1] 49910LDR R2,[R9,#8]:LDR R2,[R2] 49920LDR R3,[R9]:LDR R3,[R3] 49930LDR R4,[R9,#5*8] 49940LDR R5,[R9,#4*8] 49950LDR R6,[R9,#3*8] 49960LDR R7,[R9,#6*8] 49970.mappixlp 49980LDRB R8,[R1],#step24:LDR R9,[R4,R8,LSL #2] 49990LDRB R8,[R2],#step24:LDR R10,[R5,R8,LSL #2] 50000LDRB R8,[R3],#step24:LDR R11,[R6,R8,LSL #2] 50010STMIA R7!,{R9,R10,R11} 50020SUBS R0,R0,#1:BNE mappixlp 50030MOVS PC,R14 50040] 50050WHEN 423 50060[OPT Z 50070.mappix% 50080LDR R0,sxloc 50090LDR R1,[R9]:LDR R1,[R1] 50100LDR R2,[R9,#1*8] 50110LDR R3,[R9,#2*8] 50120LDR R4,[R9,#3*8] 50130LDR R5,[R9,#4*8] 50140LDR R6,[R9,#5*8] 50150LDR R7,[R9,#6*8] 50160LDR R8,[R9,#7*8] 50170LDR R9,[R9,#8*8] 50180STMFD SP !,{R14} 50190.mappixlp 50200LDR R10,[R1],#4 50210AND R11,R10,#&FF00 50220LDR R11,[R2,R11,LSR #6] 50230AND R12,R10,#&FF:LDR R12,[R7,R12,LSL #2]:ADD R14,R12,R11 50240AND R12,R10,#&FF0000:LDR R12,[R8,R12,LSR #14]:ADDS R14,R14,R12 50250MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50260AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 50270AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 50280MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50290AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADD R14,R12,R11 50300AND R12,R10,#&FF0000:LDR R12,[R4,R12,LSR #14]:ADDS R14,R14,R12 50310MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50320AND R11,R10,#&FF000000 50330LDR R11,[R2,R11,LSR #22] 50340AND R12,R10,#&FF:LDR R12,[R7,R12,LSL #2]:ADD R14,R12,R11 50350AND R12,R10,#&FF0000:LDR R12,[R8,R12,LSR #14]:ADDS R14,R14,R12 50360MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50370AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 50380AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 50390MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50400AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADD R14,R12,R11 50410AND R12,R10,#&FF0000:LDR R12,[R4,R12,LSR #14]:ADDS R14,R14,R12 50420MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50430SUBS R0,R0,#2:BNE mappixlp 50440LDMFD SP !,{PC}^ 50450] 50460WHEN 422 50470[OPT Z 50480.mappix% 50490LDR R0,sxloc 50500LDR R1,[R9]:LDR R1,[R1] 50510LDR R2,[R9,#1*8] 50520LDR R3,[R9,#2*8] 50530LDR R5,[R9,#4*8] 50540LDR R6,[R9,#5*8] 50550LDR R7,[R9,#6*8] 50560LDR R9,[R9,#8*8] 50570STMFD SP !,{R14} 50580.mappixlp 50590LDR R10,[R1],#4 50600AND R11,R10,#&FF00 50610LDR R11,[R2,R11,LSR #6] 50620AND R12,R10,#&FF0000:LDR R12,[R7,R12,LSR #14]:ADDS R14,R12,R11 50630MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50640AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 50650AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 50660MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50670AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADDS R14,R12,R11 50680MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50690AND R11,R10,#&FF000000 50700LDR R11,[R2,R11,LSR #22] 50710AND R12,R10,#&FF0000:LDR R12,[R7,R12,LSR #14]:ADDS R14,R12,R11 50720MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50730AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 50740AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 50750MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50760AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADDS R14,R12,R11 50770MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 50780SUBS R0,R0,#2:BNE mappixlp 50790LDMFD SP !,{PC}^ 50800] 50810ENDCASE 50820[OPT Z 50830.xsample% 50840LDR R0,[R9]:LDR R0,[R0] 50850LDR R1,[R9,#8] 50860LDR R2,[R9,#2*8] 50870LDR R3,[R9,#3*8]:LDR R3,[R3] 50880LDR R4,[R9,#4*8]:LDR R4,[R4] 50890MOV R11,R4 50900.xsamplelp 50910LDMIA R1,{R5,R6,R7} 50920SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#12 50930SUBS R12,R3,#1 50940BEQ xdonediv 50950.xdivlp 50960CMP R12,R11 50970BCC xdivlp2 50980LDMIA R1!,{R8,R9,R10}:MLA R5,R8,R11,R5:MLA R6,R9,R11,R6:MLA R7,R10,R11,R7 50990SUBS R12,R12,R11:MOV R11,R4 51000BNE xdivlp 51010B xdonediv 51020.xdivlp2 51030LDMIA R1,{R8,R9,R10} 51040SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#12 51050ADD R5,R5,R8:ADD R6,R6,R9:ADD R7,R7,R10 51060SUBS R12,R12,#1:BNE xdivlp 51070.xdonediv 51080STMIA R2!,{R5,R6,R7} 51090SUBS R0,R0,#1:BPL xsamplelp 51100MOVS PC,R14 51110] 51120ENDCASE 51130IFcompression=5 THEN 51140[OPT Z 51150.firstcode DCD 0 51160.oldcode DCD 0 51170.codesize DCD setcodes%+1 51180.stack DCD stk% 51190.sp DCD stk% 51200.maxcode DCD clearcode%+2 51210.maxcodesize DCD 2*clearcode% 51220.LZWdecode% 51230LDR R2,firstcode:LDR R3,oldcode:LDR R4,stack:LDR R5,codesize 51240LDR R6,sp:LDR R7,maxcode:LDR R8,maxcodesize 51250LDR R10,[R9]:LDR R10,[R10] 51260LDR R11,[R9,#8]:LDR R11,[R11] 51270LDR R12,[R9,#24] 51280STMFD SP !,{R14} 51290.lzwloop 51300CMP R6,R4 51310BHI lzwunstack 51320.lzwengine 51330BL getcode 51340CMP R0,#clearcode% 51350BEQ lzwclear 51360MOV R1,R0 51370CMP R0,R7 51380STRCSB R2,[R6],#1 51390MOVCS R0,R3 51400CMP R0,#clearcode% 51410BCC lzwdonepush 51420.lzwpushtable 51430LDR R14,[R12,R0,LSL #2] 51440STRB R14,[R6],#1 51450MOV R0,R14,LSR #16 51460CMP R0,#clearcode% 51470BCS lzwpushtable 51480.lzwdonepush 51490LDR R2,[R12,R0,LSL #2] 51500BIC R2,R2,#&FF0000 51510BIC R2,R2,#&FF000000 51520STRB R2,[R6],#1 51530CMP R7,#4096 51540BCS lzwnocode 51550ORR R0,R2,R3,LSL #16 51560STR R0,[R12,R7,LSL #2] 51570ADD R7,R7,#1 51580CMP R7,R8 51590BCC lzwnocode 51600CMP R8,#4096 51610ADDCC R5,R5,#1 51620MOVCC R8,R8,LSL #1 51630] 51640IFflag=1500 THEN 51650[OPT Z 51660ORRCC R8,R8,#1 51670] 51680ENDIF 51690[OPT Z 51700.lzwnocode 51710MOV R3,R1 51720CMP R6,R4 51730BLS lzwengine 51740.lzwunstack 51750LDRB R0,[R6,#-1]! 51760.lzwloopend 51770STRB R0,[R11],#1 51780SUBS R10,R10,#1 51790BNE lzwloop 51800STR R2,firstcode:STR R3,oldcode:STR R5,codesize 51810STR R6,sp:STR R7,maxcode:STR R8,maxcodesize 51820LDMFD SP !,{PC}^ 51830.lzwclear 51840MOV R0,#0 51850MOV R3,R12 51860.lzwdefaulttable 51870STR R0,[R3],#4 51880ADD R0,R0,#1:CMP R0,#clearcode% 51890BCC lzwdefaulttable 51900MOV R5,#setcodes%+1 51910MOV R7,#clearcode% 51920MOV R8,R7,LSL #1 51930] 51940IFflag=1500 THEN 51950[OPT Z 51960SUB R8,R8,#1 51970] 51980ENDIF 51990[OPT Z 52000ADD R7,R7,#2 52010BL getcode 52020MOV R2,R0 52030MOV R3,R0 52040MOV R6,R4 52050B lzwloopend 52060.curbit DCD 0 52070.lastbit DCD 0 52080.buf DCD buf% 52090.getcode 52100STMFD SP !,{R6,R7,R8} 52110ADR R6,curbit 52120LDMIA R6,{R6,R7,R8} 52130ADD R1,R5,R6 52140CMP R1,R7 52150BCS needmoredata 52160.simplecode 52170ADD R7,R8,R6,LSR #3 52180BIC R7,R7,#3 52190LDMIA R7,{R0,R7} 52200] 52210IFflag=1500 THEN 52220[OPT Z 52230EOR R1,R0,R0,ROR #16 52240BIC R1,R1,#&FF0000 52250MOV R0,R0,ROR #8 52260EOR R0,R0,R1,LSR #8 52270EOR R1,R7,R7,ROR #16 52280BIC R1,R1,#&FF0000 52290MOV R7,R7,ROR #8 52300EOR R7,R7,R1,LSR #8 52310ANDS R1,R6,#31:MOVNE R0,R0,LSL R1:RSBNE R1,R1,#32:ORRNE R0,R0,R7,LSR R1 52320RSB R1,R5,#32 52330MOV R0,R0,LSR R1 52340] 52350ELSE 52360[OPT Z 52370ANDS R1,R6,#31:MOVNE R0,R0,LSR R1:RSBNE R1,R1,#32:ORRNE R0,R0,R7,LSL R1 52380MVN R1,#0:BIC R0,R0,R1,LSL R5 52390] 52400ENDIF 52410[OPT Z 52420ADD R6,R6,R5 52430STR R6,curbit 52440LDMFD SP !,{R6,R7,R8} 52450MOV PC,R14 52460.needmoredata 52470STMFD SP !,{R2,R3,R4} 52480MOV R3,R7,LSR #3 52490SUB R0,R3,#2 52500LDRB R0,[R8,R0] 52510STRB R0,[R8] 52520SUB R0,R3,#1 52530LDRB R0,[R8,R0] 52540STRB R0,[R8,#1] 52550LDR R1,[R9,#16] 52560LDR R1,[R1] 52570] 52580IFflag=1500 THEN 52590[OPT Z 52600MOV R0,#256 52610MOV R3,#256 52620] 52630ELSE 52640[OPT Z 52650SWI "OS_BGet" 52660MOVS R3,R0 52670BEQ simplecode1 52680] 52690ENDIF 52700[OPT Z 52710SUB R6,R6,R7 52720ADD R6,R6,#16 52730ADD R0,R0,#2 52740MOV R7,R0,LSL #3 52750STR R7,lastbit 52760MOV R0,#4 52770ADD R2,R8,#2 52780SWI "OS_GBPB" 52790.simplecode1 52800LDMFD SP !,{R2,R3,R4} 52810B simplecode 52820] 52830ENDIF 52840IFrange% THEN 52850[OPT Z 52860.maxmin% 52870LDR R0,[R9]:LDR R0,[R0] 52880LDR R1,[R9,#8] 52890LDR R2,min 52900LDR R3,max 52910.maxminlp 52920LDR R4,[R1],#4 52930CMP R4,R3:MOVCS R3,R4 52940CMP R4,R2:MOVCC R2,R4 52950SUBS R0,R0,#1:BNE maxminlp 52960STR R2,min 52970STR R3,max 52980MOVS PC,R14 52990.min DCD F 53000.max DCD 0 53010] 53020ENDIF 53030IFsharpen% THEN 53040sharp=(col+1)*4:IFsharpen%<>8 sharpmul%=F/(sharpen%-8) 53050[OPT Z 53060.sharp% 53070LDR R0,[R9]:LDR R0,[R0] 53080LDR R1,[R9,#8] 53090LDR R2,[R9,#16] 53100LDR R3,[R9,#24] 53110LDR R4,[R9,#32] 53120] 53130CASE sharpen% OF 53140WHEN 8,9,12,16,24 53150OTHERWISE 53160[OPT Z 53170MOV R8,#sharpmul% AND &FF 53180ORR R8,R8,#sharpmul% AND &FF00 53190MOV R9,#(sharpmul% >> 16) AND &FF 53200ORR R9,R9,#(sharpmul% >> 16) AND &FF00 53210] 53220ENDCASE 53230[OPT Z 53240.sharplp 53250LDR R5,[R1,#-sharp] 53260LDR R6,[R1,#sharp]:ADD R5,R5,R6 53270LDR R6,[R1],#4:ADD R5,R5,R6 53280LDR R6,[R3,#-sharp]:ADD R5,R5,R6 53290LDR R6,[R3,#sharp]:ADD R5,R5,R6 53300LDR R6,[R3],#4:ADD R5,R5,R6 53310LDR R6,[R2,#-sharp]:ADD R5,R5,R6 53320LDR R6,[R2,#sharp]:ADD R5,R5,R6 53330LDR R6,[R2],#4 53340MOV R6,R6,LSR #1 53350MOV R7,#sharpen% 53360MUL R7,R6,R7 53370SUBS R5,R7,R5,LSR #1 53380MOVCC R5,#0 53390] 53400CASE sharpen% OF 53410WHEN 8,9 53420[OPT Z 53430MOV R6,R5,LSL #1 53440] 53450WHEN 10 53460[OPT Z 53470MOV R6,R5 53480] 53490WHEN 12 53500[OPT Z 53510MOV R6,R5,LSR #1 53520] 53530WHEN 16 53540[OPT Z 53550MOV R6,R5,LSR #2 53560] 53570WHEN 24 53580[OPT Z 53590MOV R6,R5,LSR #3 53600] 53610OTHERWISE 53620[OPT Z 53630MOV R6,R5,LSR #16 53640EOR R5,R5,R6,LSL #16 53650MUL R7,R8,R5 53660MUL R5,R9,R5 53670MUL R10,R6,R8 53680MUL R6,R9,R6 53690ADDS R10,R5,R10 53700ADDCS R6,R6,#&10000 53710ADDS R7,R7,R10,LSL #16 53720ADC R6,R6,R10,LSR #16 53730MOV R6,R6,LSL #(32-27) 53740ORRS R6,R6,R7,LSR #27 53750ADDCS R6,R6,#1 53760] 53770ENDCASE 53780[OPT Z 53790CMP R6,#F:MOVCS R6,#F 53800STR R6,[R4],#4 53810SUBS R0,R0,#1 53820BNE sharplp 53830MOVS PC,R14 53840] 53850ENDIF 53860IFhist%ORequal% THEN 53870[OPT Z 53880.histo% 53890LDR R0,[R9]:LDR R0,[R0] 53900LDR R1,[R9,#8] 53910LDR R2,[R9,#16] 53920.histlp 53930LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 53940MOV R3,R3,LSR #bits-8 53950] 53960IFcol=2 THEN 53970[OPT Z 53980ADD R3,R3,R3,LSL #1 53990LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 54000LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 54010MOV R3,R3,LSR #bits-8 54020ADD R3,R3,R3,LSL #1:ADD R3,R3,#1 54030LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 54040LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 54050MOV R3,R3,LSR #bits-8 54060ADD R3,R3,R3,LSL #1:ADD R3,R3,#2 54070] 54080ENDIF 54090[OPT Z 54100LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 54110SUBS R0,R0,#1 54120BNE histlp 54130MOVS PC,R14 54140] 54150ENDIF 54160IFequal% THEN 54170[OPT Z 54180.histequal% 54190LDR R0,[R9]:LDR R0,[R0] 54200LDR R1,[R9,#8] 54210LDR R2,[R9,#16] 54220.equallp 54230LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 54240MOV R3,R3,LSR #bits-8 54250] 54260IFcol=2 THEN 54270[OPT Z 54280LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 54290MOV R3,R3,LSR #bits-8 54300ADD R3,R3,R3,LSL #1 54310LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 54320LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 54330MOV R3,R3,LSR #bits-8 54340ADD R3,R3,R3,LSL #1:ADD R3,R3,#1 54350LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 54360LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 54370MOV R3,R3,LSR #bits-8 54380ADD R3,R3,R3,LSL #1:ADD R3,R3,#2 54390] 54400ENDIF 54410[OPT Z 54420LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 54430SUBS R0,R0,#1 54440BNE equallp 54450MOVS PC,R14 54460] 54470ENDIF 54480CASE rflag OF 54490WHEN 201,800,801,1000,1001 54500[OPT Z 54510.rlexpand% 54520LDR R0,[R9] 54530LDR R1,[R0] 54540LDR R2,[R9,#8]:LDR R2,[R2] 54550LDR R3,[R9,#16] 54560LDR R4,[R3] 54570CMP R4,#1:MOVLTS PC,R14 54580LDR R5,[R9,#24]:LDR R5,[R5] 54590.rle 54600STRB R2,[R1],#1 54610SUB R4,R4,#1 54620CMP R1,R5 54630TEQNE R4,#0 54640BNE rle 54650.rlexit 54660STR R1,[R0] 54670STR R4,[R3] 54680MOVS PC,R14 54690] 54700WHEN 902 54710WHEN 903 54720[OPT Z 54730.unpack16 54740MOV r4,#31 ; 5 bits set mask 54750MOV r5,#512 ; Pixel counter 54760.unpack16loop 54770LDRB r3,[r0],#1 ; Get half a pixel from the sprite 54780LDRB r2,[r0],#1 ; Get second half of the pixel 54790ORR r2,r3,r2,LSL#8 ; Combine data into one pixel 54800AND r3,r2,#31 ; Get red pixel 54810 54820STRB r3,[r1,#0] ; Store in buffer 54830AND r3,r2,r4,LSL#5 ; Get green pixel 54840MOV r3,r3,LSR#5 54850 54860STRB r3,[r1,#512] ; Store in buffer 54870AND r3,r2,r4,LSL#10 ; Get blue pixel 54880MOV r3,r3,LSR#10 54890 54900STRB r3,[r1,#1024] 54910ADD r1,r1,#1 54920SUBS r5,r5,#1 54930BNE unpack16loop 54940MOVS r15,r14 54950 54960.unpack 54970ADD R2,R0,#768 54980MOV R4,#&F 54990.unpackloop 55000LDR R3,[R0],#4 55010MOV R5,#0 55020.bitloop 55030AND R6,R3,R4,LSL R5 55040MOV R6,R6,LSR R5 55050ADD R5,R5,#4 55060AND R7,R3,R4,LSL R5 55070MOV R7,R7,LSR R5 55080ADD R5,R5,#4 55090STRB R7,[R1],#1 55100STRB R6,[R1],#1 55110CMP R5,#32 55120BNE bitloop 55130CMP R2,R0 55140BNE unpackloop 55150MOVS PC,R14 55160] 55170ENDCASE 55180 55190IFplanar%<0 THEN 55200C%=7:IFflag=2600 C%=15 55210[OPT Z 55220.plancnv% 55230LDR R0,sxloc 55240LDR R1,[R9]:LDR R1,[R1] 55250LDR R3,[R9,#8]:LDR R3,[R3] 55260LDR R4,[R9,#16]:LDR R4,[R4] 55270MOV R9,#C% 55280.planelp 55290MOV R7,#0 55300MOV R5,R3 55310] 55320FORN%=1TOplanes% 55330[OPT Z 55340LDR R6,[R5],R4 55350] 55360IFflag=2600 THEN 55370[OPT Z 55380MOV R6,R6,LSL #8 55390BIC R6,R6,#&FF000000 55400ORR R6,R6,R6,LSR #16 55410] 55420ENDIF 55430[OPT Z 55440MOV R6,R6,LSR R9 55450AND R6,R6,#1 55460ORR R7,R7,R6,LSL #(N%-1) 55470] 55480NEXT 55490[OPT Z 55500STRB R7,[R1],#1 55510SUBS R9,R9,#1:MOVMI R9,#C% 55520] 55530IFflag=2600 THEN 55540[OPT Z 55550MOVMI R3,R5 55560] 55570ELSE 55580[OPT Z 55590ADDMI R3,R3,#1 55600] 55610ENDIF 55620[OPT Z 55630SUBS R0,R0,#1:BNE planelp 55640MOVS PC,R14 55650] 55660ENDIF 55670NEXT 55680CASE ncol OF 55690WHEN 255:size%=1 55700WHEN 63:size%=1 55710WHEN 15:size%=2 55720WHEN 3:size%=4 55730WHEN 1:size%=8:IFm$="C" size%=2 55740IFm$="D" size%=4 55750IFm$="T" size%=2 55760ENDCASE 55770CASE flag OF 55780WHEN 501:IFinfo% PRINT"Reading interlaced GIF" 55790sz%=sx%*sy%:datacache%=FNdim(sz%+100):buff%=datacache%:rowbytes%=sx%:rowstogo%=-1 55800FORY%=0TOsy%-1STEP8:X%=buff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 55810FORY%=4TOsy%-1STEP8:X%=buff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 55820FORY%=2TOsy%-1STEP4:X%=buff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 55830FORY%=1TOsy%-1STEP2:X%=buff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 55840ENDCASE 55850IFgamma<>1 THEN 55860k=1/gamma:FORC%=0TO255 55870IFr%(C%) r%(C%)=((r%(C%)/F)^k)*F 55880IFg%(C%) g%(C%)=((g%(C%)/F)^k)*F 55890IFb%(C%) b%(C%)=((b%(C%)/F)^k)*F 55900NEXT 55910ENDIF 55920rmax=F:gmax=F:bmax=F 55930IFcol=0 THEN 55940IFinput<9 THEN 55950FORC%=0TO255:r%(C%)=r%(C%)*rwt+g%(C%)*gwt+b%(C%)*bwt:NEXT 55960ELSE 55970IFinput<>422 THEN 55980rmax=F*rwt:gmax=F*gwt:bmax=F*bwt 55990FORC%=0TO255:r%(C%)=r%(C%)*rwt:g%(C%)=g%(C%)*gwt:b%(C%)=b%(C%)*bwt:NEXT 56000ENDIF 56010ENDIF 56020ENDIF 56030IFNOTorder% PROCadjustpalette(1/ydiv%/xdiv%,0) 56040IFrange% THEN 56050IFinfo% PRINT"Scanning data to compute parameters for '-range'" 56060IForder% THEN 56070Y%=0:REPEAT SYShour%,Y%*100DIVsy% 56080PROCiprow(xp%()):CALLmaxmin%,xp%(1,0),totvals2%:Y%+=1 56090UNTILY%=sy% OR!min<255 AND!max+255>=F 56100ELSE 56110Y%=0:ysamp%=1:REPEAT SYShour%,Y%*100DIVy% 56120PROCscaledpixelrow(cl%()):CALLmaxmin%,cl%(1,0),totvals%:Y%+=1 56130UNTILY%=y% OR !min<255 AND !max+255>=F 56140ENDIF 56150IF!max+255>=F AND!min<255 range%=FALSE:range$="No point in '-range' on this image" 56160IFrange% PROCadjustpalette(F/(!max-!min),!min/ydiv%/xdiv%):range$="Input image maximum "+STR$(!max/F*100)+"% minimum "+STR$(!min/F*100)+"%" 56170PROCrewind:IFinfo% PRINTrange$ 56180ENDIF 56190IFhist% ORequal% THEN 56200IFequal% IFinfo% PRINT"Scanning data to compute parameters for '-equal'" 56210IForder% THEN 56220FORyr%=0TOsy%-1:SYShour%,yr%*100DIVsy% 56230PROCiprow(xp%()):CALLhisto%,xp%(1,0),vals%(0,0),sx% 56240NEXT 56250ELSE 56260ysamp%=1:FORyr%=0TOy%-1:SYShour%,yr%*100DIVy% 56270PROCscaledpixelrow(cl%()):CALLhisto%,cl%(1,0),vals%(0,0),x% 56280NEXT 56290ENDIF 56300IFinfo% PRINT"Done. Now processing the picture" 56310ENDIF 56320IFinput<>422 THEN 56330FORC%=0TO255 56340IFr%(C%)<0 r%(C%)=0 56350IFg%(C%)<0 g%(C%)=0 56360IFb%(C%)<0 b%(C%)=0 56370IFr%(C%)>rmax r%(C%)=rmax 56380IFg%(C%)>gmax g%(C%)=gmax 56390IFb%(C%)>bmax b%(C%)=bmax 56400NEXT 56410ENDIF 56420IFhist% THEN 56430M%=0:ZM%=-1:FORC%=0TOcol 56440FORZ%=0TO256:IFvals%(Z%,C%)>M% M%=vals%(Z%,C%):ZM%=Z% 56450NEXT:NEXT 56460IFZM%=-1 OR okinfo%=0 THEN=100 56470IF col>0 THEN 56480MODE66:ht=500 56490IFMODE<>66 MODE16:ht=400 56500LINE0,6,2000,6 56510ELSE 56520MODE18:ht=400:LINE0,6,1024,6 56530ENDIF 56540M=M%/(ht*2-8):FORC%=0TOcol:CASE C% OF 56550WHEN 0:GCOL1 56560WHEN 1:GCOL2 56570WHEN 2:GCOL4 56580ENDCASE 56590IF col>0 THEN 56600FORZ%=0TO256:IFvals%(Z%,C%) X%=Z%*3+C%<<1:LINEX%,8,X%,vals%(Z%,C%)/M+8 56610NEXT 56620ELSE 56630FORZ%=0TO256:IFvals%(Z%,C%) X%=Z%<<2:RECTANGLE FILLX%,8,2,vals%(Z%,C%)/M 56640NEXT 56650ENDIF 56660NEXT 56670IFc% CLOSE#c%:c%=0 56680IFcc% CLOSE#cc%:cc%=0 56690IFccc% CLOSE#ccc%:ccc%=0 56700SYS"Hourglass_Off" 56710=100 56720ENDIF 56730oname$="p"+STR$m+m$:IFrange% oname$+="r" 56740IFequal% oname$+="e" 56750IFsharpen% oname$+="s"+STR$sharpen% 56760IFblack% oname$+="b"+STR$black% 56770IFgamma<>1 A%=@%:@%=&1020100:oname$+="g"+STR$gamma:@%=A% 56780IFbright%=16 oname$+="b" 56790xsp%=x%:ysp%=y%:IFrotate% SWAP xsp%,ysp% 56800CASE m OF 56810WHEN -1:xwords%=xsp%:sz%=xwords%*ysp%:Y%=ysp%:PROCgetoutput(sz%,0,xwords%,Y%) 56820base%=ram% 56830OTHERWISE:xwords%=xsp%/size%+3.9999ANDNOT3:sz%=xwords%*ysp%:X%=xsp%:Y%=ysp% 56840IFncol=1 THEN 56850CASE m$ OF 56860WHEN"C":!rowinc=xwords%:xwords%=xwords%*4:sz%=xwords%*ysp%:X%=xsp%*4:Y%=ysp%*4 56870WHEN"T":!rowinc=xwords%:xwords%=xwords%*3:sz%=xwords%*ysp%:X%=xsp%*4:Y%=ysp%*3 56880WHEN"D":!rowinc=xwords%:xwords%=xwords%*2:sz%=xwords%*ysp%:X%=xsp%*2:Y%=ysp%*2 56890ENDCASE 56900ENDIF 56910A%=Y%:PROCgetoutput(sz%,1024,xwords%,Y%) 56920ram%!4=0:ram%!8=16:ram%!12=16:SYS&2e,&109,ram% 56930SYS&2e,&10f,ram%,oname$,(ncol<63)AND1,X%,Y%,spm 56940base%=ram%+ram%!8:base%!(5*4)=A%-1:!base%=!base%-Y%*xwords%+A%*xwords% 56950ram%!12=ram%!12-Y%*xwords%+A%*xwords% 56960pal%=base%+11*4:base%+=base%!(8*4) 56970CASE ncol OF 56980WHEN 15 56990CASE m$ OF 57000WHEN "P" 57010FORZ%=0TO15:PROCcol(Z%,(palette%!(Z%<<2)>>8)AND&F0F0F0):NEXT 57020WHEN "D" 57030FORZ%=0TO7:A%=0:IFZ%AND1 A%+=&F0 57040IFZ%AND2 A%+=&F000 57050IFZ%AND4 A%+=&F00000 57060PROCcol(Z%,A%):NEXT 57070WHEN "C" 57080FORZ%=0TO15:A%=0:IFZ%AND4 A%+=&F0 57090IFZ%AND3 A%+=(Z%AND3)*5<<12:IF(Z%AND3)=1 A%+=&1000 57100IFZ%AND8 A%+=&F00000 57110PROCcol(Z%,A%):NEXT 57120WHEN "T" 57130FORZ%=0TO15:A%=Z%<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 57140WHEN "" 57150FORZ%=0TO15:A%=(Z%AND7)/7*15+.2<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 57160ENDCASE 57170WHEN 3 57180IFm$="C" THEN 57190PROCcol(0,0):PROCcol(1,&F0F000):PROCcol(2,&F000F0):PROCcol(3,&F0F0) 57200ELSE 57210FORZ%=0TO3:A%=Z%*5<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 57220ENDIF 57230WHEN 1:PROCcol(0,0):PROCcol(1,&F0F0F0) 57240ENDCASE 57250ENDCASE 57260LOCAL ERROR 57270ON ERROR LOCAL:RESTORE ERROR:PROCSave:ERROR ERR,REPORT$+" internal ("+STR$ERL+")" 57280SYS"Hourglass_LEDs",3 57290ysamp%=1:nl%()=0:step%=4*(col+1) 57300addr%=base%*size%:rowstep%=xwords%*size%:colstep%=1:dist%=xsp%-1 57310IFrotate% THEN 57320SWAP colstep%,rowstep% 57330addr%+=(ysp%-1)*colstep%:colstep%=-colstep%:dist%=(ysp%-1)*colstep% 57340ENDIF 57350outlim%=(base%+xwords%*Y%)*size%-1:oddcolstep%=-colstep%:oddstep%=-step% 57360IForder% PROCadjustpalette(1/ydiv%/xdiv%,0) 57370IFsy%=y% AND sx%=x% AND range%=FALSE AND sharpen%=FALSE AND equal%=FALSE THEN 57380IFdither% THEN 57390FORyr%=0 TO y%-1:SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 57400PROCiprow(cl%()):cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 57410IFyr%AND1 THEN 57420CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 57430ELSE 57440A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 57450ENDIF 57460NEXT 57470ELSE 57480I%=step%:FORyr%=0TOy%-1:SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 57490PROCiprow(cl%()):B%=x%:A%=addr%:addr%+=rowstep%:CALLfs%,colstep%,cl%(1,0),I%,A%,I%,B% 57500NEXT 57510ENDIF 57520ELSE 57530IFequal% THEN 57540PROCrewind:Havg%=SUM(vals%())/256/(col+1):DIM new%(256,col) 57550FORB%=0TOcol:R%=0:Hint%=0:FORZ%=0TO256:L%=R%:Hint%+=vals%(Z%,B%) 57560WHILEHint%>Havg%:Hint%-=Havg%:R%+=1:ENDWHILE 57570new%(Z%,B%)=(L%+R%)/2*F/256 57580NEXT:NEXT 57590ENDIF 57600IFsharpen% THEN 57610IForder% THEN 57620yread%=sy%-1:PROCiprow(rm1%()):IFequal% PROCfit2(rm1%()) 57630FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(sx%+1,B%)=rm1%(sx%,B%):NEXT 57640ELSE 57650yread%=y%-1:PROCscaledpixelrow(rm1%()):IFequal% PROCfit(rm1%()) 57660FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(x%+1,B%)=rm1%(x%,B%):NEXT 57670ENDIF 57680rm2%()=rm1%() 57690ENDIF 57700IForder% THEN 57710FORyr%=0 TO y%-1 57720SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 57730IFsy%=y% THEN 57740PROCsharppixelrow(cl%()) 57750ELSE 57760ysamp%-=1:IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 57770IFydiv%=1 THEN 57780cl%()=xl%() 57790ELSE 57800IFysamp%>=ydiv% THEN 57810ysamp%-=ydiv%:cl%()=xl%()*ydiv% 57820ELSE 57830cl%()=xl%()*ysamp%:Y%=ydiv%-ysamp%:ysamp%=0 57840REPEAT 57850IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 57860IFysamp%>Y% THEN 57870ysamp%-=Y%:xl2%()=xl%()*Y%:cl%()=cl%()+xl2%():Y%=0 57880ELSE 57890Y%-=ysamp%:xl2%()=xl%()*ysamp%:cl%()=cl%()+xl2%():ysamp%=0 57900ENDIF 57910UNTIL Y%=0 57920ENDIF 57930ysamp%+=1 57940ENDIF 57950ENDIF 57960cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 57970IFyr%AND1 THEN 57980CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 57990ELSE 58000A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 58010ENDIF 58020NEXT 58030ELSE 58040FORyr%=0 TO y%-1 58050SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 58060IFsharpen% THEN 58070IFyread% yread%-=1:PROCscaledpixelrow(rm%()):IFequal% PROCfit(rm%()) 58080FORB%=0TOcol:rm%(0,B%)=rm%(1,B%):rm%(x%+1,B%)=rm%(x%,B%):NEXT 58090CALL sharp%,cl%(1,0),rm%(1,0),rm1%(1,0),rm2%(1,0),totvals% 58100SWAP rm2%(),rm1%():rm1%()=rm%() 58110ELSE 58120PROCscaledpixelrow(cl%()):IFequal% PROCfit(cl%()) 58130ENDIF 58140cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 58150IFyr%AND1 THEN 58160CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 58170ELSE 58180A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 58190ENDIF 58200NEXT 58210ENDIF 58220ENDIF 58230PROCSave 58240=0 58250DEF PROCgetoutput(A%,E%,B%,RETURN C%) 58260IFA%>max% AND rotate%=FALSE THEN 58270C%=max%DIVB%+1:A%=xwords%*C%+E%:first%=TRUE:o%=OPENOUTf$ 58280ELSE 58290A%+=E% 58300ENDIF 58310IFspritearea%<0 THENram%=FNdim(A%) ELSEram%=spritearea% 58320!ram%=A% 58330ENDPROC 58340DEF PROCflushoutput 58350IFspritearea%<0 ANDoksave% THEN 58360IFhflip% SYS&2e,256+47,ram%,oname$ 58370A%=base%:IFfirst% A%=ram%+4:first%=FALSE 58380SYS12,2,o%,A%,addr%DIVsize%-A% 58390ENDIF 58400addr%=base%*size% 58410ENDPROC 58420DEF PROCSave 58430IFc% CLOSE#c%:c%=0 58440IFcc% CLOSE#cc%:cc%=0 58450IFccc% CLOSE#ccc%:ccc%=0 58460CASE m OF 58470WHEN -1:IFspritearea%<0 ANDoksave% THEN 58480IFo% PROCflushoutput ELSESYS"OS_File",10,f$,&004,,ram%,ram%+sz% 58490ENDIF 58500WHEN -2:o%=OPENOUTf$:BPUT#o%,pnm$ 58510IFvflip% SYS&2e,256+33,ram%,oname$ 58520IFhflip% SYS&2e,256+47,ram%,oname$ 58530CASE pnm$ OF 58540WHEN "P1" 58550BPUT#o%,"# "+f$+".pbm (options "+oname$+")" 58560BPUT#o%,STR$xsp%+" "+STR$ysp% 58570FORY%=0TOysp%-1:B%=base%+Y%*xwords% 58580FORX%=0TOxsp%-1:IFB%?(X%>>3)AND(1<<(X%AND7)) BPUT#o%,"1"; ELSEBPUT#o%,"0"; 58590NEXT 58600BPUT#o%,"" 58610NEXT 58620WHEN "P4" 58630BPUT#o%,"# "+f$+".pbm (options "+oname$+") binary encoded" 58640BPUT#o%,STR$xsp%+" "+STR$ysp% 58650FORX%=0TO255:code%?X%=X%<<7 OR X%<<5AND&40 OR X%<<3AND&20 OR X%<<1AND&10 OR X%>>1AND8 OR X%>>3AND4 ORX%>>5AND2 ORX%>>7:NEXT 58660FORY%=0TOysp%-1:B%=base%+Y%*xwords% 58670FORX%=0TOxsp%-1STEP8:BPUT#o%,code%?(B%?(X%>>3)):NEXT 58680NEXT 58690WHEN "P2" 58700BPUT#o%,"# "+f$+".pgm (options "+oname$+")" 58710BPUT#o%,STR$xsp%+" "+STR$ysp% 58720BPUT#o%,"15" 58730FORY%=0TOysp%-1:B%=base%+Y%*xwords% 58740FORX%=0TOxsp%-1:C%=B%?(X%>>1):IFX%AND1 C%=C%>>4 ELSEC%=C%AND15 58750BPUT#o%," "+STR$C%; 58760NEXT 58770BPUT#o%,"" 58780NEXT 58790WHEN "P5" 58800BPUT#o%,"# "+f$+".pgm (options "+oname$+") binary encoded" 58810BPUT#o%,STR$xsp%+" "+STR$ysp% 58820BPUT#o%,"15" 58830FORY%=0TOysp%-1:B%=base%+Y%*xwords% 58840FORX%=0TOxsp%-1:C%=B%?(X%>>1):IFX%AND1 C%=C%>>4 ELSEC%=C%AND15 58850BPUT#o%,C% 58860NEXT 58870NEXT 58880ENDCASE 58890CLOSE#o%:o%=0 58900OTHERWISE 58910IFvflip% SYS&2e,256+33,ram%,oname$ 58920IFhflip% SYS&2e,256+47,ram%,oname$ 58930IFncol=1ANDm$="T" THEN 58940FORX%=(xsp%*4-1)DIV8*8+6TO6STEP-8 58950SYS&2e,&12e,ram%,oname$,X% 58960SYS&2e,&12e,ram%,oname$,X% 58970NEXT 58980ENDIF 58990IFspritearea%<0 ANDoksave% THEN 59000IFo% PROCflushoutput ELSESYS&2e,&10c,ram%,f$ 59010ENDIF 59020ENDCASE 59030IFo% CLOSE#o%:o%=0:OSCLI"settype "+f$+" ff9" 59040SYS"Hourglass_Off" 59050ENDPROC 59060DEFPROCdefpal 59070FORC%=0TO255 59080r%(C%)=(C%AND7 OR (C%AND16)>>1)/15*F 59090g%(C%)=(C%AND3 OR (C%AND&60)>>3)/15*F 59100b%(C%)=(C%AND3 OR (C%AND8)>>1 OR (C%AND128)>>4)/15*F 59110NEXT 59120ENDPROC 59130DEFPROCdefpal2 59140r%(0)=F:g%(0)=F:b%(0)=F 59150ENDPROC 59160DEFPROCdefpal4 59170r%()=15,10,5,0:FORC%=0TO3:r%(C%)=r%(C%)/15*F:NEXT 59180g%()=r%():b%()=r%() 59190ENDPROC 59200DEFPROCdefpal16 59210r%()=15,13,11,9,7,5,3,0,0,14, 0,13,14,5,15, 0 59220g%()=15,13,11,9,7,5,3,0,4,14,12, 0,14,8,11,10 59230b%()=15,13,11,9,7,5,3,0,9, 0, 0, 0,11,0, 0,15 59240FORC%=0TO15:r%(C%)=r%(C%)/15*F:g%(C%)=g%(C%)/15*F:b%(C%)=b%(C%)/15*F:NEXT 59250ENDPROC 59260DEFPROCipal63 59270PTR#c%=&38:DIM rpal%(15),gpal%(15),bpal%(15) 59280FORC%=0TO15:D%=BGET#c% 59290rpal%(C%)=BGET#c%>>4 AND 7 59300gpal%(C%)=BGET#c%>>4 AND 3 59310bpal%(C%)=BGET#c%>>4 AND 7 59320D%=FNW:NEXT 59330FORC%=0TO255 59340r%(C%)=(rpal%(C%AND15)OR(C%AND16)>>1)/15*F 59350g%(C%)=(gpal%(C%AND15)OR(C%AND&60)>>3)/15*F 59360b%(C%)=(bpal%(C%AND15)OR(C%AND128)>>4)/15*F 59370NEXT 59380ENDPROC 59390DEFPROCipal(D%) 59400PTR#c%=&38 59410FORC%=0TOD%-1:D%=BGET#c% 59420r%(C%)=(BGET#c%>>4)/15*F 59430g%(C%)=(BGET#c%>>4)/15*F 59440b%(C%)=(BGET#c%>>4)/15*F 59450D%=FNW:NEXT 59460ENDPROC 59470DEF PROCnopal 59480FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%() 59490ENDPROC 59500DEF PROCcol(A%,B%) 59510B%=B%<<8ORB%<<4OR&10:pal%!(A%*8)=B%:pal%!(A%*8+4)=B% 59520ENDPROC 59530DEF FNbits(A%) 59540IFA%=1 THEN="1 bit per pixel" ELSE=STR$A%+" bits per pixel" 59550DEF FNfits 59560LOCALZ%,s$ 59570FORZ%=1TO80:s$+=CHR$BGET#c%:NEXT 59580=s$ 59590DEF FNuc(a$) 59600LOCALZ%,z$,b$ 59610FORZ%=1TOLENa$ 59620z$=MID$(a$,Z%,1) 59630IFz$>="a"IFz$<="z" z$=CHR$(ASCz$-32) 59640b$+=z$:NEXT 59650=b$ 59660DEF FNdim(A%) 59670LOCAL B% 59680IFflex% THEN 59690B%=nextlocation%:A%=A%+3ANDNOT3:nextlocation%+=A% 59700SYS"Wimp_SlotSize",-1,-1 TO currentslot% 59710IFcurrentslot%+&8000<nextlocation% THEN 59720SYS "Wimp_SlotSize",nextlocation%-&8000,-1 TO currentslot% 59730IFcurrentslot%+&8000<nextlocation% ERROR 42,"Can't get enough memory to process image" 59740ENDIF 59750ELSE 59760IFworkspace%<0 THEN 59770DIM B% A% 59780ELSE 59790B%=workspace%:workspace%+=A%+3ANDNOT3:IFworkspace%>worklimit% ERROR42,"Not enough workspace" 59800ENDIF 59810ENDIF 59820=B% 59830DEF FNW=FNW1(c%) 59840DEF FNW1(c%)=BGET#c% OR BGET#c%<<8 OR BGET#c%<<16 OR BGET#c%<<24 59850DEF FNHW=BGET#c% OR BGET#c%<<8 59860DEF FNbeHW=BGET#c%<<8 OR BGET#c% 59870DEF FNbeW=BGET#c%<<24 OR BGET#c%<<16 OR BGET#c%<<8 OR BGET#c% 59880DEF FNtiff(T%) 59890CASE T% OF 59900WHEN 1:=BGET#c% 59910WHEN 2:LOCALs$,t$:REPEATs$+=t$:t$=CHR$BGET#c%:UNTILt$=CHR$0:=s$ 59920WHEN 3:IFbigendian THEN=BGET#c%<<8 OR BGET#c% ELSE=BGET#c% OR BGET#c%<<8 59930WHEN 4:IFbigendian THEN=FNbeW ELSE=FNW1(c%) 59940ENDCASE 59950ERROR 42,"Silly TIFF tag:"+STR$T% 59960DEF PROCnextstrip 59970rowstogo%=striprows% 59980stripptr+=1:PTR#c%=st%(stripptr) 59990IFcompression=5 THEN 60000!firstcode=0:!oldcode=0:!codesize=setcodes%+1:!stack=stk%:!sp=stk% 60010!maxcode=clearcode%+2:!maxcodesize=2*clearcode%:!curbit=0:!lastbit=0 60020ENDIF 60030ENDPROC 60040DEF PROCwatford(wtsx%,RETURN rep%,RETURN wt%,X%,c%) 60050CALLrlexpand%,wtsx%,rep%,wt%,X% 60060REPEAT C%=BGET#c%:CASE C%>>6 OF 60070WHEN 0:?X%=C%:X%+=1:wt%=C% 60080WHEN 1:wt%-=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60090WHEN 2:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60100WHEN 3:wt%+=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60110ENDCASE 60120UNTILX%=wtsx% 60130ENDPROC 60140DEF PROCsize 60150IFscale% THEN 60160IFsx%<=320 IFsy%<=256 xmul%=xmul%*2:ymul%=ymul%*2 60170IFsy%<=sx%/2 ymul%=ymul%*2 60180ENDIF 60190ENDPROC 60200DEF PROCreduce(RETURN A%,RETURN B%) 60210LOCAL C%,D%:C%=A%:D%=B% 60220REPEAT IFC%<D% SWAP C%,D% 60230C%=C%MODD% 60240UNTILC%=0 60250A%=A%DIVD%:B%=B%DIVD% 60260ENDPROC 60270DEF PROCreadpixelrow(z%()) 60280IFrows% THEN 60290rows%-=1:IFsx%=x% THEN 60300PROCiprow(z%()) 60310ELSE 60320PROCiprow(xp%()):CALLxsample%,xmul%,xdiv%,z%(1,0),xp%(1,0),x% 60330ENDIF 60340ELSE 60350z%()=0 60360ENDIF 60370ENDPROC 60380DEF PROCsharppixelrow(z%()) 60390IFrows% THEN 60400rows%-=1:IFsx%=x% THEN 60410IFsharpen% PROCsharp(z%()) ELSEPROCiprow(z%()):IFequal% PROCfit2(z%()) 60420ELSE 60430IFsharpen% PROCsharp(xp%()) ELSEPROCiprow(xp%()):IFequal% PROCfit2(xp%()) 60440CALLxsample%,xmul%,xdiv%,z%(1,0),xp%(1,0),x% 60450ENDIF 60460ELSE 60470z%()=0 60480ENDIF 60490ENDPROC 60500DEF PROCsharp(z%()) 60510yread%-=1:IFyread% PROCiprow(rm%()):IFequal% PROCfit2(rm%()) 60520FORB%=0TOcol:rm%(0,B%)=rm%(1,B%):rm%(sx%+1,B%)=rm%(sx%,B%):NEXT 60530CALL sharp%,z%(1,0),rm%(1,0),rm1%(1,0),rm2%(1,0),totvals2% 60540SWAP rm2%(),rm1%():rm1%()=rm%() 60550ENDPROC 60560DEF PROCscaledpixelrow(z%()) 60570IFsy%=y% THEN 60580PROCreadpixelrow(z%()) 60590ELSE 60600ysamp%-=1:IFysamp%=0 PROCreadpixelrow(xl%()):ysamp%=ymul% 60610IFydiv%=1 THEN 60620z%()=xl%() 60630ELSE 60640IFysamp%>=ydiv% THEN 60650ysamp%-=ydiv%:z%()=xl%()*ydiv% 60660ELSE 60670LOCALY%:z%()=xl%()*ysamp%:Y%=ydiv%-ysamp%:ysamp%=0 60680REPEAT 60690IFysamp%=0 PROCreadpixelrow(xl%()):ysamp%=ymul% 60700IFysamp%>Y% THEN 60710ysamp%-=Y%:xl2%()=xl%()*Y%:z%()=z%()+xl2%():Y%=0 60720ELSE 60730Y%-=ysamp%:xl2%()=xl%()*ysamp%:z%()=z%()+xl2%():ysamp%=0 60740ENDIF 60750UNTIL Y%=0 60760ENDIF 60770ysamp%+=1 60780ENDIF 60790ENDIF 60800ENDPROC 60810DEF PROCfit(z%()) 60820CALLhistequal%,z%(1,0),new%(0,0),x% 60830ENDPROC 60840DEF PROCfit2(z%()) 60850CALLhistequal%,z%(1,0),new%(0,0),sx% 60860ENDPROC 60870DEF PROCadjustpalette(mul,sub) 60880IFmul=1 AND sub=0 ENDPROC 60890FORC%=0TO255 60900r%(C%)=(r%(C%)-sub)*mul+1:g%(C%)=(g%(C%)-sub)*mul+1:b%(C%)=(b%(C%)-sub)*mul+1 60910NEXT 60920IF ham THEN 60930 FORC%=0TO15*4STEP4:ltable!C%=(ltable!C%-sub)*mul+1:NEXT 60940ENDIF 60950IF input=422 THEN 60960FORC%=0TO255 60970rpal%(C%)=(rpal%(C%)-sub)*mul+1:gpal%(C%)=(gpal%(C%)-sub)*mul+1 60980bpal%(C%)=(bpal%(C%)-sub)*mul+1:table%(C%)=(table%(C%)-sub)*mul+1 60990NEXT 61000ENDIF 61010ENDPROC 61020 61030DEF PROCrefill 61040IFstriprows%>0 PROCnextstrip 61050SYS12,4,c%,datacache%,cache%:rowstogo%=cacherows%:buff%=datacache% 61060IFinput=24 rb%=buff%+rbo%:gb%=buff%+gbo%:bb%=buff%+bbo% 61070ENDPROC 61080 61090DEF PROCiprow(z%()) 61100CASE rflag OF 61110WHEN 0:CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),buff%:buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 61120ENDPROC 61130 61140WHEN 901:SYS12,4,c%,rb%,sx%:SYS12,4,cc%,gb%,sx%:SYS12,4,ccc%,bb%,sx% 61150CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb%:ENDPROC 61160WHEN 902 61170 IF slave% THEN 61180 SYS 12,4,c%,tspace%,768 61190 A%=tspace% 61200 ELSE 61210 A%=V9Area%+offset% 61220 ENDIF 61230 B%=rb% 61240 CALL unpack 61250 offset%+=768 61260 REM SYS12,4,c%,rats%,rowbytes%:CALLunpack% 61270CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb%:ENDPROC 61280 61290WHEN 903 61300 IF slave% THEN 61310 SYS 12,4,c%,tspace%,1024 61320 A%=tspace% 61330 ELSE 61340 A%=V9Area%+offset% 61350 ENDIF 61360 B%=rb% 61370 CALL unpack16 61380 offset%+=1024 61390 REM SYS12,4,c%,rats%,rowbytes%:CALLunpack% 61400CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb%:ENDPROC 61410 61420ENDCASE 61430ENDPROC 61440 61450DEF PROCrewind 61460rows%=sy%:CASE flag OF 61470WHEN 0:PTR#c%=st% 61480 61490WHEN 900:PTR#c%=0 61500WHEN 901:PTR#c%=0:PTR#cc%=0:PTR#ccc%=0 61510WHEN 902 61520 IF slave% THEN 61530 PTR#c%=st% 61540 ELSE 61550 offset%=20 61560 ENDIF 61570WHEN 903 61580 IF slave% THEN 61590 PTR#c%=st% 61600 ELSE 61610 offset%=20 61620 ENDIF 61630ENDCASE 61640 61650IFcache% THEN 61660IFcache%<filesize% SYS12,4,c%,datacache%,cache%:rowstogo%=cacherows% 61670buff%=datacache% 61680IFinput=24 rb%=buff%+rbo%:gb%=buff%+gbo%:bb%=buff%+bbo% 61690ENDIF 61700ENDPROC 61710 61720DEF PROCchange_LCA(new%) 61730IF mono$=">" THEN SYS "WVCGrab_LCA",3:ENDPROC 61740IF board_is_16_bit% OR allow_dithering% THEN 61750 SYS "WVCGrab_LCA",new% 61760 CALL set_8bit 61770 IF dithered%=1 THEN 61780 PROCiconset(4,4,1<<21,1<<21) 61790 ELSE 61800 PROCiconset(4,4,1<<21,0) 61810 ENDIF 61820ENDIF 61830ENDPROC 61840 61850DEF FNfind_slot_for_V9 61860DIM slot_b% 16 61870V9_slot%=-1 61880FOR s%=0 TO 3 61890 !slot_b%=0 61900 slot_b%!4=0 61910 SYS "XPodule_ReadHeader",,,slot_b%,s% 61920 manuf%=slot_b%?5 OR (slot_b%?6<<8) 61930 prod%=slot_b%?3 OR (slot_b%?4<<8) 61940 IF manuf%=9 AND prod%=82 THEN V9_slot%=s% 61950NEXT 61960=V9_slot% 61970 61980DEF PROCget_board_version 61990slot%=FNfind_slot_for_V9 62000IF slot%=-1 ERROR 42,"Hawk V9 not present":END 62010r0=0 62020modstat%=-1 62030REPEAT 62040SYS "Podule_EnumerateChunks",r0,,,slot% TO r0,r1,r2 62050IF r2=%11110011 THEN 62060 modstat%=r0-1 62070 size%=r1 62080ENDIF 62090UNTIL modstat%<>-1 OR r0=0 62100 62110DIM buff% size% 62120SYS "Podule_ReadChunk",modstat%,,buff%,slot% 62130m$="" 62140FOR l%=0 TO size%-1 62150 m$+=CHR$(buff%?l%) 62160NEXT 62170 62180CASE LEFT$(m$,1) OF 62190 WHEN "S" 62200 board_is_16_bit%=FALSE 62210 allow_dithering%=FALSE 62220 allow_mono%=FALSE 62230 WHEN "D" 62240 allow_dithering%=TRUE 62250 board_is_16_bit%=TRUE 62260 allow_mono%=TRUE 62270 OTHERWISE 62280 allow_dithering%=FALSE 62290 board_is_16_bit%=FALSE 62300 allow_mono%=FALSE 62310ENDCASE 62320ENDPROC
� > !RunImage debug%=� �get_board_version (� � � � �:�error(0) 2+version$="Version 2.00 (13th Oct 1992)" < �init F� � �error(-1) P� Z!�wimpservice(�(pollcode),pb%) d� � n� x� �init ��setvars �%taskhandle%=�taskinit("FastGrab") �ș "WVCGrab_Refresh",0 ��setupwindows ��fudgeinit �� � debug% � 21 � �assemble �� 6 �$A%=livearea%+60:B%=&20100:�blank ��getchoices ��installonbar ��modechanged ��cwin(3) �cwin(4) @!rdb=w%(3,0):!udb=w%(3,0):!livewb=w%(3,0):livewb!4=livearea% 0!spritearea=livearea%:!spritead=livearea%+16 "!dragging%=0:!pollad=pb% ,� PROCadjustlive 6 �calclive @�shutlivedisplay J,ș "Wimp_SlotSize",-1,-1 � originalslot% T� ^ h� �round(� value%,round%) r� (value% � round%)=0 � |,value%=((value%+round%) � round%)*round% �� � �� �fudgeinit �� � debug% � 21 ��dolivecode ��dograbcode �� 6 �livename$="pic" �dragtype%=-1 �nextlocation%=� �� livearea% &20800 �!livearea%=&20700 �livearea%!4=1 livearea%!8=16 $(livearea%+20)="grabbed" livearea%!32=&3F &livearea%!36=&7F 0livearea%!40=&00 :livearea%!44=&1F Dlivearea%!48=&2C Nlivearea%!52=&2C Xlivearea%!56=15 b!livedumpad%=livearea%+60 l� set_8bit v� � �A� �add_palette_to_sprite(sprite_area%,sprite_ad%,sprite_pal%) � � pal%,z% �pal%=sprite_ad%+44 �sprite_ad%!32+=2048 �sprite_ad%!36+=2048 �sprite_ad%!00+=2048 �sprite_area%!12+=2048 �)� Bung a palette into the sprite area � �z%=0�255 �% B%=(z%<<8) � (z%<<16) � (z%<<24) �$ pal%!(z%*8)=B%:pal%!(z%*8+4)=B% �� <�palette_for_sprite(sprite_area%,sprite_ad%,sprite_pal%) � � �live_grey *"!livedumpad%=livearea%+60+2048 4old_sat%=saturation% >saturation%=0 H$satad%="0" R�saturation \;�add_palette_to_sprite(livearea%,livearea%+16,livepal%) f�optimise_liveplot p� z �� �live_colour �saturation%=old_sat% �$satad%=�(saturation%) ��saturation �!livedumpad%=livearea%+60 �sptr%=livearea%+16 �sptr%!32-=2048 �sptr%!36-=2048 �sptr%!00-=2048 �livearea%!12-=2048 �8�palette_for_sprite(livearea%,livearea%+16,livepal%) ��optimise_liveplot �� � �dograbcode � GAP &2000,L% 0 $� Pass%=8 � 10 � 2 . P%=GAP 8[ B OPT Pass% L.VRAM_Grab V3SWI 22 ; Into SVC mode `MOV R0,R15 j�R R0,R0,#3<<26 t6TEQP R15,R0 ; FIQ's off too... ~ �>SWI "WVCGrab_MemBases" ; Get base of podule space � �<LDRB R8,[R1] ; RAS only Refresh cycle �MOV R9,#0 � �A�R r4,r1,#&1000 ; Page mode read cycle address �<�R r3,r1,#&1800 ; Terminate cycle address �H�R r2,r1,#&800 ; Initiate Read/SR to memory transfer �3�R r2,r2,#&008 ; VRAM address 8 �=�R r7,r1,#&1000 ; Page mode read (CAS low) �KADD r7,r7,#&001C ; This gets around the pipelining issue �LDR R10,pagestep LDR R11,pixelstep .next_row_down DLDRB R8,[R2],R10 ; Initiate SR to memory transfer I;LDRB R8,[R7] ; Get a pixel from VRAM - fixes pipeline (SUB R7,R7,#16 2 .row_read <;LDRB R8,[R7],R11 ; Get a pixel from VRAM F<STRB R8,[R5],#1 ; Store it in the buffer P=CMP R7,R3 ; End of the row reached? ZBLT row_read d n:SUB R7,R7,#&800 ; Do the next row down xADD R7,R7,#&10 �LDR R8,[R7,#&800] �CMP R2,R4 �BLE next_row_down �TEQP R15,#0 �MOVNV R6,R6 �MOVS R15,R14 � .pagestep � EQUD 8 �.pixelstep � EQUD 4 � �.mask EQUD 32767 � .read16bit ,; r0=output address, r1=line number reqd SWI "OS_EnterOS" "LMOV r6,r0 ; Bung address for data (a line) into r6 ,MOV r0,r15 6:�R r0,r0,#3<<26 ; Change processor mode @TEQP r15,r0 J TLDR r3,packR3 ^LDR r4,packR4 hLDR r5,packR5 rMOV r0,#0 |9MOV r1,r1,LSL#3 ; Convert line number �9LDR r8,[r3,r1] ; Initiate read cycle � �LDR r7,mask � �P;LDR r8,[r4,r0,LSL#2] ; Get a pixel from the VRAM into r8 (16bit) �;ADD r0,r0,#1 � �.get_another_byte �OLDR r8,[r4,r0,LSL#2] ; Get a pixel from the VRAM into r8 (16bit) � �0;MOV r8,#%11000<<10 ; Blue data �0;�R r8,r8,#%11101<<5 ; Green data �.;�R r8,r8,#%11000 ; Red data ADD r0,r0,#1 &;� r8,r8,r7 ; Get bottom fifteen bits 0=� r9,r8,#&ff00 ; Get top byte from 15 bits :MOV r9,r9,LSR#8 DHSTRB r8,[r6],#1 ; Store bottom byte in output buffer NESTRB r9,[r6],#1 ; Store top byte in output buffer XDCMP r0,#512 ; Did we read the full line yet? bABNE get_another_byte ; If not, get on with the job lLDR r8,[r5,#0] vTEQP r15,#0 �MOVNV r0,R0 �MOV r15,r14 � � .packline �SWI "OS_EnterOS" �,; r0=output address, r1=line number reqd �?MOV R12,R0 ; Address for data (a line) �MOV R0,R15 ��R R0,R0,#3<<26 �TEQP R15,R0 �LDR R3,packR3 �LDR R4,packR4 �LDR R5,packR5 MOV R0,#0 MOV R1,R1,LSL#3 3LDR R8,[R3,R1] ; Initiate read .Next_Byte *?LDR R8,[R4,R0,LSL #2] ; Get a pixel from the VRAM 4=ADD R0,R0,#1 ; Increment pixel counter >FLDR R7,[R4,R0,LSL #2] ; Get a second pixel from the VRAM H3ADD R0,R0,#1 ; Inc pixel ctr R� R9,R8,#&F \� R10,R7,#&F f�R R11,R10,R9,LSL #4 p;STRB R11,[R12,#512] ; Bung byte into buffer z� R9,R8,#&F0 �� R10,R7,#&F0 ��R R11,R9,R10,LSR #4 �;STRB R11,[R12,#256] ; Bung byte into buffer �� R9,R8,#&F00 �MOV R9,R9,LSR #4 �� R10,R7,#&F00 ��R R11,R9,R10,LSR #8 �;STRB R11,[R12],#1 ; Bung byte into buffer �GCMP R0,#&200 ; Have we done a complete line yet? �BNE Next_Byte �5LDR R8,[R5,#0] ; Terminate cycle �TEQP R15,#0 �MOVNV R6,R6 MOV R15,R14 .membaseR0 $ EQUD 0 ..membaseR1 8 EQUD 0 B.packR3 L EQUD 0 V.packR4 ` EQUD 0 j.packR5 t EQUD 0 ~ � .set_8bit �SWI 22 �SWI "WVCGrab_MemBases" �:ADD R0,R0,#&2000 ; &2000=Paging reg for V9 Mk I �MOV R1,#&10 �STRB R1,[R0] �;ADD r0,r0,#&1000 ; &3000=Paging reg for V9 Mk II �STRB R1,[R0] � �TEQP R15,#0 �MOVNV R0,R0 �MOVS R15,R14 .set_12bit SWI 22 SWI "WVCGrab_MemBases" :ADD R0,R0,#&2000 ; &2000=Paging reg for V9 Mk I (MOV R1,#0 2STRB R1,[R0] <;ADD r0,r0,#&1000 ; &3000=Paging reg for V9 Mk II FSTRB R1,[R0] PTEQP R15,#0 ZMOVNV R0,R0 dMOVS R15,R14 n x.Refresh_Frame �SWI 22 �SWI "WVCGrab_MemBases" �ADD R0,R1,#&1800 �LDR R2,[R1,#0] �MOV R0,#256 �.Refresh_Loop �,LDR R2,[R1,R0] ; Refresh Cycle �SUBS R0,R0,#1 �BNE Refresh_Loop �TEQP R15,#0 �MOVNV R0,R0 �MOVS R15,R14 � ] � Pass% !ș "WVCGrab_MemBases" � r0,r1 "!packR3=r1 � &800 ,!packR4=r1 � &1000 6!packR5=r1 � &1800 @� J T� �dolivecode ^� livegap% &1200,L% 0 h� pass%=8 � 10 � 2 rP%=livegap% |[ � OPT pass% �.live_grab �,SWI 22 ; Interrupts off �MOV R0,R15 ��R R0,R0,#3<<26 �ETEQP R15,R0 ; Turn off fast interrupts too (sorry...) �6LDR R1,livebaseR1 ; Get base of podule space �9LDR R5,livedumpad% ; Get address for 8bpp output �9�R R2,R1,#&1000 ; Page mode read cycle address �>�R R6,R1,#&800 ; Initiate pixel read cycle address �5MOV R9,#&1800 ; Terminate cycle address � �MOV R11,#0 .livefield_poll 4LDR R8,[R6] ; Start pixel read cycle &2LDR R8,[R1,R9] ; Terminate read cycle 0/ADD R11,R11,#1 ; Increment counter :-CMP R11,#&8000 ; Too many tries? D1BGT signalgone ; If not, complain... N3TST r8,#&4000 ; Video signal present? X<BEQ livefield_poll ; If no signal, wait for a while bMOV R11,#0 l vMOV R11,#1 �.livevert_poll �4LDR R8,[R6] ; Start pixel read cycle �2LDR R8,[R1,R9] ; Terminate read cycle �/ADD R11,R11,#1 ; Increment counter �)CMP R11,#&8000 ; How long... �BGT signalgone �TST R8,#&2000 �BEQ livevert_poll � �MOV R11,#0 �.livevert_poll1 �.LDR R8,[R6] ; Start pixel read �2LDR R8,[R1,R9] ; Terminate pixel read )ADD R11,R11,#1 ; Inc counter +CMP R11,#&8000 ; Too many yet? BGT signalgone TST R8,#&2000 *BNE livevert_poll1 4 >1LDR R8,[R1] ; Read word from VRAM HBLDR R12,fielding ; Grabbing single field at the moment? RCMP R12,#0 \DBEQ bothfields ; If not, don't care which field this is fILDR R11,evenfield ; Otherwise, find out which field is required pMOV R11,R11,LSL #14 z� R12,R8,#1<<14 �6CMP R12,R11 ; Is this the field to do? �,BEQ bothfields ; If so, grab it �CB livefield_poll ; Otherwise, wait for the next frame... � �.bothfields �9STR R8,[R6] ; Start SR to memory transfer �6STR R8,[R1,R9] ; Terminate transfer cycle �MSTR R8,[R1] ; RAS only refresh, to allow serial VRAM transfer �MOV R10,#&1000 �MOV R12,#0 � �.livenext_row �MOV r0,#0 ;.liveEnd_Blank ; Wait for the end blank signal 4LDR R8,[R6] ; Start pixel read cycle $ .-LDR R8,[R1,R9] ; Terminate cycle 8 B3ADD R0,R0,#1 ; Increment row counter LCMP R0,#&8000 VBGT signalgone `1TST R8,#&1000 ; Blank signal found? jBEQ liveEnd_Blank t ~MOV R11,#0 �1.liverow_data_in ; Read data into VRAM �.LDR R8,[R6] ; Start read cycle �2LDR R8,[R1,R9] ; Terminate read cycle �ADD R11,R11,#1 �CMP R11,#&8000 �BGT signalgone �TST R8,#&1000 �BNE liverow_data_in � �JSTRB R8,[R6],#8 ; Pass VRAM address to V9 and start read cycle �2STRB R8,[R1,R9] ; Terminate read cycle �ACMP R6,R2 ; Read 512*16bit words into VRAM yet? :BLT livenext_row ; If not, get the next row !!! �R R4,R1,#&1000 �R R3,R1,#&1800 *�R R2,R1,#&800 ; Cycle type 2a (-�R R2,R2,#8 ; VRAM Address &08 21�R R7,R1,#&1000 ; Page mode read cycle <:�R R7,R7,#&20 ; VRAM Address &14 at the start F PLDR R10,livepagestep ZLDR R11,livepixelstep d n5ADD r9,r1,#&2000 ; Paging register address xADD r12,r1,#&3000 � �.livenext_row_down �@;MOV r0,#1<<6 ; Bit 6 controls hardware dithering �2;STR r0,[r12] ; Store in paging reg �;STR r0,[r9] �;MOV r0,#0 �;STR r0,[r12] �;STR r0,[r9] � �?LDRB R8,[R2],R10 ; Initiate read cycle for next line �>SUB R7,R7,#16 ; Decrement page mode read counter � �.liverow_read @LDRB R8,[R7],R11 ; Do page mode read to scan the line DSTRB R8,[R5],#1 ; Put the 8bpp data into the live buffer 4CMP R7,R3 ; Read a whole line yet? "7BLT liverow_read ; If not, get another pixel , 69SUB R7,R7,#&800 ; Decrement page mode counter @ADD R7,R7,#&10 J3LDR R8,[R7,#&800] ; Set page mode address T1CMP R2,R4 ; Read 256 lines yet? ^;BLT livenext_row_down; If not, get another line !!! hLDR R0,signalpresent rCMP R0,#0 |BEQ signalback �TEQP R15,#0 �MOVNV R0,R0 �MOVS PC,R14 �.signalback �MOV R0,#1 �STR R0,signalpresent �MOV R0,#0 �ASWI "WVCGrab_Refresh" ; Turns refresh off, signal is back �ADR R7,signal �B udicon �.signalgone �LDR R0,signalpresent �CMP R0,#0 BNE changeicon TEQP R15,#0 MOVNV R6,R6 &MOVS PC,R14 0.changeicon :MOV R0,#0 DSTR R0,signalpresent NMOV R0,#1 XASWI "WVCGrab_Refresh" ; Turns refresh on, signal has gone bADR R7,nosignal l.udicon vLDMIA R7,{R1-R3} �ADR R7,barspace �STMIA R7,{R1-R3} �ADR R1,iconb �SWI "Wimp_SetIconState" �TEQP R15,#0 �MOVNV R6,R6 �MOVS PC,R14 �.signal �EQUS "barsignal"+�0+�0 � ALIGN � .nosignal �EQUS "barnosignal" � EQUB 0 ALIGN .signalpresent EQUD 1 .barspace *EQUS "barsignal" 4 EQUB 0 > ALIGN H.livebaseR1 R EQUD 0 \ .fielding f EQUD 0 p.evenfield z EQUD 1 �.livedumpad% � EQUD 0 �.livepagestep �EQUD 16 �.livepixelstep � EQUD 8 � .iconb �;EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 �;EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 �;EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 �;EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 �;EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0 �] � pass% ș "WVCGrab_MemBases" � ,r1 !livebaseR1=r1 $� . 8� �setvars Blongsp%=8400 Ltemplatespace%=8096 Vmaxmenusize%=1000 `�� block% 4,pb% 2048,iconsp% templatespace%,mouseb% 20,menub% 10000,longitems% longsp%,mb% 30048,magt% 32,livepal% 256,grabpal% 256,modeb% 100 jliveplot%=liveplot% ttempsize%=8000 ~� tempb% tempsize%,w%(17,2) �� IICblock% 10 �ctempb%=tempb% �$(modeb%+4)="a0-9"+�0 �'submode$="Mode|*modeb%,modeb%+4,4|" �� set%=0 � 28 � 4 �magt%!set%=1 �� �$block%="TASK" �wksp%=iconsp% � spnd%=iconsp%+templatespace% �close%=� �quitting%=� quithand%=0 scrappy%=� saved8%=� saved12%=� (oldmode%=� 2live%=� < grabex%=� Fcfsid%=� Poldmenu%=-1 Zslave%=� dqflag%=� nc%=� x� �� �taskinit(task$) �Eș "Wimp_Initialise",200,!block%,task$ � wimpversion%,taskhandle% �=taskhandle% �� �setupwindows � � os% �-sh%=�("<FastGrab$Dir>.Resources.Sprites") �/� sh%=0 � 214,"Sprite file cannot be found" �� sprites% �#sh%+16 �!sprites%=�#sh%+16 �sprites%!4=0 �sprites%!8=16 �sprites%!12=16 � �#sh% Dș "OS_SpriteOp",266,sprites%,"<FastGrab$Dir>.Resources.Sprites" @ș "Wimp_OpenTemplate",,"<FastGrab$Dir>.Resources.Templates" B�ltemp("Parameters",w%(1,1),0):� Change 0 to -1 for new icons! "modead%=�iconad(1,0) ,x1ad%=�iconad(1,1) 6x2ad%=�iconad(1,2) @y1ad%=�iconad(1,3) Jy2ad%=�iconad(1,4) Tsharpenad%=�iconad(1,22) ^blackad%=�iconad(1,30) hgammaad%=�iconad(1,31) r!�ltemp("PALWindow",w%(2,1),0) |brightad%=�iconad(2,3) �contad%=�iconad(2,8) �satad%=�iconad(2,13) ��ltemp("LiveWin",w%(3,1),0) �w%(3,1)?39=&FF � �ltemp("LivePane",w%(4,1),0) �w%(4,1)!68=sprites% �9w%(4,1)!(88+4+16+32*1)=w%(4,1)!(88+4+16+32*1) � 1<<22 �g� (board_is_16_bit%=� � allow_dithering%=�) � w%(4,1)!(88+4+16+32*4)=w%(4,1)!(88+4+16+32*4) � 1<<22 �"valid%=!(w%(4,1)+88+4+24+32*3) �� board_is_16_bit% � � $valid%="stb_16bit,tb_8bit" �� � $valid%="stb_12bit,tb_8bit" � �ltemp("8BitShow",w%(5,1),0) w%(5,1)?39=&FF &grabwtitlead%=wksp%-255 0 �ltemp("GrabPane",w%(6,1),0) :w%(6,1)!68=sprites% D"�ltemp("SprSaveWin",w%(7,1),0) Noutsprad%=�iconad(7,2) X"�ltemp("RawSaveWin",w%(8,1),0) boutrawad%=�iconad(8,2) l!�ltemp("Magnifier",w%(9,1),0) v%mag1ad%=�iconad(9,0):$mag1ad%="1" �%mag2ad%=�iconad(9,1):$mag2ad%="1" �#�ltemp("SpriteInfo",w%(10,1),0) �grabnamead%=�iconad(10,0) �grabmodead%=�iconad(10,1) �grabmaskad%=�iconad(10,2) �grabwidtad%=�iconad(10,3) �grabbytead%=�iconad(10,4) �grabpalad%=�iconad(10,5) �grabheigad%=�iconad(10,6) � �ltemp("RawInfo",w%(11,1),0) �rawbytesad%=�iconad(11,1) �rawwidthad%=�iconad(11,3) �rawheightad%=�iconad(11,5) rawbrightad%=�iconad(11,9) rawcontad%=�iconad(11,11) rawsatad%=�iconad(11,10) �ltemp("Info",w%(13,1),-1) *$�iconad(13,7)=version$ 4"�ltemp("ImageInfo",w%(14,1),0) >$$�iconad(14,4)=�ChangeFSIVersion H�ltemp("Query",w%(15,1),0) Rqueryad%=�iconad(15,1) \!�ltemp("SpeedWin",w%(17,1),0) fspeedad%=�iconad(17,3) pș"Wimp_CloseTemplate" z� � �� �iconad(wh%,ih%) �=!(w%(wh%,1)+112+ih%*32) � �.� �ltemp(tempname$,� address%,indirected%) �Tș "Wimp_LoadTemplate",,ctempb%+4,wksp%,spnd%,-1,tempname$,0 � ,,wksp%,,,,found% �G� found%=0 ș "Wimp_CloseTemplate":� 0,"Template file is incorrect" �address%=ctempb% �D� (ctempb%-tempb%+tempsize%<400) � 0,"Templates need more space" �ctempb%+=4+88+ctempb%!88*32 �&� indirected% address%!68=sprites% �� �� �getchoices .inc%=�("<FastGrab$Dir>.Resources.Choices") � inc%=0 � $modead%="15" $$x1ad%="1" .$x2ad%="1" 8$y1ad%="1" B$y2ad%="1" Loutmode$=" " V�setflags(0) `$sharpenad%="" jcontrast%=32 tsavedcont%=32 ~saturation%=32 �old_sat%=saturation% �savedsat%=32 �brightness%=0 �savedbright%=0 �bit%=12 �dithered%=1 �+� board_is_16_bit% � allow_dithering% � � dither$=">" �� � dither$="<" �� �� allow_mono% � mono$="" � mono$="<" � (ltool$=">" 2gtool$=">" < speed%=99 F field$="" P!fielding=0 Z!evenfield=0 d�fieldmenu n cache$="" x$modeb%="15" �grabsize%=0 �livesize%=2 ��select(26,0) ��select(27,0) ��select(28,0) �$blackad%="32" ��select(29,0) �$gammaad%="2.2" �� �mode%=�#inc% �$modead%=�mode% ��#inc%,$x1ad% ��#inc%,$y1ad% �#inc%,$x2ad% �#inc%,$y2ad% !options%=�#inc% � (�#inc%)<<8 "�setflags(options%) ,$sharpenad%=�(�#inc%) 6brightness%=�#inc% @savedbright%=brightness% Jcontrast%=�#inc% Tsavedcont%=contrast% ^saturation%=�#inc% hsavedsat%=saturation% rold_sat%=saturation% |tool%=�#inc% �"� (tool% � 1) bit%=12 � bit%=8 �(� (tool% � 2) ltool$=">" � ltool$="" �(� (tool% � 4) gtool$=">" � gtool$="" �(� (tool% � 8) cache$=">" � cache$="" �A� (tool% � 16) field$=">":!fielding=1 � field$="":!fielding=0 �!evenfield=(tool% � 32)>>4 �(� (tool% � 128) mono$=">" � mono$="" �� allow_mono%=� � mono$="<" �� board_is_16_bit% � �F � (tool% � 64) � dithered%=1:dither$=">" � dithered%=0:dither$="" � �change_LCA(dithered%) �� � ș "WVCGrab_LCA",0 � set_8bit � allow_dithering% � dithered%=1 & dither$=">" 0 � : dithered%=0 D dither$="<" N � X� bold_sat%=saturation% l�fieldmenu vspeed%=�#inc% �%modeval%=�#inc%:$modeb%=�modeval% �grabsize%=�#inc% �livesize%=�#inc% �$sel%=�#inc%:� sel% �select(26,1) �$sel%=�#inc%:� sel% �select(27,1) �$sel%=�#inc%:� sel% �select(28,1) �$blackad%=�(�#inc%) �$sel%=�#inc%:� sel% �select(29,1) ��#inc%,$gammaad% �precise%=�#inc% �� precise% � � on%=32:outmode$="P" � � s%=7 � 32 B � s%=on% �iconset(1,s%,1<<21,1<<21) � �iconset(1,s%,1<<21,0) � � �#inc% *� 4%grabsize$=�setsizemenu(grabsize%) >%livesize$=�setsizemenu(livesize%) H�speed:$speedad%=�speed% R!�contrast:$contad%=�contrast% \'�brightness:$brightad%=�brightness% f$�saturation:$satad%=�saturation% p� bit%=12 � z �iconset(4,3,1<<21,0) �� � �iconset(4,3,1<<21,1<<21) �� �� �� �setflags(set%) �� set% � 256 � ��iconset(1,6,1<<21,0) ��iconset(1,5,1<<21,1<<21) �� ��iconset(1,6,1<<21,1<<21) ��iconset(1,5,1<<21,0) �� �Ȏ set% � 3 � � 0 outmode$=" " on%=7 $� 1 . outmode$="C" 8 on%=8 B� 2 L outmode$="D" V on%=9 `� 3 j outmode$="T" t on%=10 ~� �� s%=7 � 32 �A � s%=on% �iconset(1,s%,1<<21,1<<21) � �iconset(1,s%,1<<21,0) �� ��select(11,(set% � 4)>>2) ��select(12,(set% � 8)>>3) ��select(13,(set% � 16)>>4) ��select(14,(set% � 32)>>5) ��select(15,(set% � 64)>>6) ��select(16,(set% � 128)>>7) ��select(23,(set% � 512)>>9) �!�select(24,(set% � 1024)>>10) �!�select(25,(set% � 2048)>>11) !�select(27,(set% � 4096)>>12) � � �select(icon%,select%) ('�iconset(1,icon%,1<<21,select%<<21) 2� < F� �wimpservice(event%,pb%) PȎ event% � Z� 0 d Ȏ !dragging% � n � 1,2,3 x �dopaldrag � � 4 � �dospeeddrag � � �� 1 � �redrawwin �� 2 � Ȏ !pb% � � � w%(3,0) � �dopane(w%(3,0)) � � w%(5,0) � �dopane(w%(5,0)) � � ș "Wimp_OpenWindow",,pb% � � 3 Ȏ !pb% � " � w%(3,0) , �shutlivedisplay 6 � w%(5,0) @ �dwin(5) J !grabwb=0 T � gtool$=">" �dwin(6) ^ h! ș "Wimp_DeleteWindow",,pb% r w%(�windowid(!pb%),2)=� | � �� 6 � �clickwindow �� 7 � �dragend �� 8 � �handlekey �� 9 � �menuselect �� 17,18 � �message �� �� � � �shutlivedisplay �dwin(3) !livewb=0 &� ltool$=">" �dwin(4) 0live%=� :!maskad=%1100000110001 D@� !signalpresent $barspace="bardorms" � $barspace="bardormn" N!mb%=-1 Xmb%!4=iconbar% bmb%!8=0 lmb%!12=0 vș "Wimp_SetIconState",,mb% �� � �� �dumpsprite �-$(mb%+4)="Sprite not saved - discard it?" �7ș "Wimp_ReportError",mb%,7,"FastGrab" � ,response% �� response%=2 =� � =� � �� �shutdown(arg%) �� arg% � � � � saved12% � (debug%=�) � �M �query(2,"Image not saved in FastGrab: are you sure you want to quit?") � � � � ! � slave% � !/ $mb%="<FastGrab$Dir>.Resources.TwelveBit" !! ș "OS_FSControl",27,mb%,,0 ! slave%=� !* � !4� !>close%=� !H� quitting% � !R$ ș "Wimp_GetCaretPosition",,mb% !\ mb%!24=&1FC !f" ș "Wimp_SendMessage",8,mb%,0 !p* ș "Wimp_SendMessage",8,mb%,quithand% !z� !�*ș "Wimp_CloseDown",taskhandle%,"TASK" !�� !�� !� !�� �query(qnum%,message$) !�qflag%=qnum% !�$queryad%=message$ !�1�menu(15,rightscr%/2-738/2,topscr%/2+276/2,0) !�� !� !�� �redrawwin !� Ȏ !pb% � !� � w%(2,0) "( ș "Wimp_RedrawWindow",,pb% � more% " x0%=pb%!4-pb%!20 " y0%=pb%!16-pb%!24 "$ ȕ more% ". � "8 ș "Wimp_SetColour",7 "B+ ȓ Ȑ x0%+140,y0%-36,brightness%*4,20 "L) ȓ Ȑ x0%+140,y0%-80,contrast%*4,20 "V, ȓ Ȑ x0%+140,y0%-124,saturation%*4,20 "`) ș "Wimp_GetRectangle",,pb% � more% "j � "t� w%(17,0) "~( ș "Wimp_RedrawWindow",,pb% � more% "� x0%=pb%!4-pb%!20 "� y0%=pb%!16-pb%!24 "� ȕ more% "� � "� ș "Wimp_SetColour",7 "�& ȓ Ȑ x0%+140,y0%-36,speed%*2,20 "�) ș "Wimp_GetRectangle",,pb% � more% "� � "�� "�� "� "�� �dopane(toolwindow%) # Ȏ toolwindow% � # � w%(3,0) # pane%=w%(4,0) # paneopen%=(ltool$=">") #( � w%(5,0) #2 pane%=w%(6,0) #< paneopen%=(gtool$=">") #F #P% � 100,"This window is paneless!" #Z� #d!mb%=toolwindow% #n!ș "Wimp_GetWindowState",,mb% #x� mb%!32 � 1<<19 � #� �togglewindowsize(mb%) #� ș "Wimp_OpenWindow",,pb% #�" ș "Wimp_GetWindowState",,pb% #�� #�*� pb%!4<=mb%!4 towards%=� � towards%=� #�!mb%=pane% #�mb%!4=pb%!4-88 #�mb%!8=pb%!8 #�mb%!12=pb%!4-4 #�mb%!16=pb%!16 #�mb%!20=0 #�mb%!24=0 #�mb%!28=pb%!28 $� towards% � $ � paneopen% � $ ș "Wimp_OpenWindow",,mb% $" pb%!28=pane% $, � $6 ș "Wimp_OpenWindow",,pb% $@� $J ș "Wimp_OpenWindow",,pb% $T* � paneopen% ș "Wimp_OpenWindow",,mb% $^� $h� $r $|� �togglewindowsize(block%) $�win%=�windowid(!block%) $�&� IF w%(win%,1)!44<-rightscr% THEN $�� block%!4=0 $�� block%!12=rightscr%-48 $�� ENDIF $�#� IF w%(win%,1)!56>topscr% THEN $�� block%!8=48 $�� block%!16=topscr%-48 $�� ENDIF $�$block%!12=block%!4+w%(win%,1)!52 $�$block%!8=block%!16-w%(win%,1)!56 $�� $� %� �windowid(handle%) % � win% % win%=0 %&ȕ w%(win%,0)<>handle% %0 win%+=1 %:� %D =win% %N %X� �clickwindow %b %ladjust%=pb%!4 � 1 %v %�Ȏ pb%!12 � %� %�� -2 %� Ȏ pb%!16 � %� � iconbar% %� Ȏ pb%!8 � %� � 2 %� mousex%=!pb% %� mousey%=186 %�3 menu%=�cmenu(0,"FastGrab|@13'Info|Quit|",96) %� mentype%=0 %� � 4 %� � � live% � && w%(3,1)!4=rightscr%/2-livex%/2 &$ w%(3,1)!8=topscr%/2-livey%/2 &' w%(3,1)!12=rightscr%/2+livex%/2 & % w%(3,1)!16=topscr%/2+livey%/2 &*" � w%(3,1)!8<0 w%(3,1)!8=84 &4 w%(3,1)!20=0 &> w%(3,1)!24=0 &H w%(3,1)!28=-1 &R �cwin(3) &\ !rdb=w%(3,0) &f !udb=w%(3,0) &p !livewb=w%(3,0) &z% ș "Wimp_OpenWindow",,w%(3,1) &� � ltool$=">" � &� w%(4,1)!4=w%(3,1)!4-88 &� w%(4,1)!8=w%(3,1)!8 &� w%(4,1)!12=w%(4,1)!4+84 &� w%(4,1)!16=w%(3,1)!16 &� w%(4,1)!28=-1 &�( � grabex% �iconset(4,1,1<<22,0) &� �cwin(4) &�& ș "Wimp_OpenWindow",,w%(4,1) &� � &�J � !signalpresent � $barspace="barsignal" � $barspace="barnosignal" &� !mb%=-1 &� mb%!4=iconbar% ' mb%!8=0 ' mb%!12=0 '# ș "Wimp_SetIconState",,mb% '$ live%=� '. !maskad=%1100000110000 '8 � 'B � ltool$=">" � 'L !mb%=w%(4,0) 'V& ș "Wimp_GetWindowState",,mb% '` mb%!28=-1 'j" ș "Wimp_OpenWindow",,mb% 't !mb%=w%(3,0) '~& ș "Wimp_GetWindowState",,mb% '� mb%!28=w%(4,0) '�" ș "Wimp_OpenWindow",,mb% '� � '� !mb%=w%(3,0) '�& ș "Wimp_GetWindowState",,mb% '� mb%!28=-1 '�" ș "Wimp_OpenWindow",,mb% '� � '� � '� � '�� '� ( � w%(3,0) ( Ȏ pb%!8 � ( � 2 ( �livemenu (( � (2 (< � w%(4,0) (F � (pb%!8 � 4) � (P Ȏ pb%!16 � (Z � 0 (d �grab (n �showgrab (x � 1 (� �showgrab (� � 2 (�$ �menu(2,!pb%-290,pb%!4+68,0) (� � 3 (�" � bit%=12 bit%=8 � bit%=12 (� � 4 (� dithered%=dithered% � 1 (� �change_LCA(dithered%) (� � (� � (� � (pb%!8 � 2) �livemenu (� (� � w%(5,0) ) Ȏ pb%!8 � ) � 2 ) �grabmenu )" � ), � w%(6,0) )6 � (pb%!8 � 4) � )@ Ȏ pb%!16 � )J � 0 )T# �menu(1,!pb%-354,pb%!4+264,0) )^ � 1 )h" �menu(9,!pb%-136,pb%!4+64,0) )r � 2 )|" �menu(7,!pb%-122,pb%!4+84,0) )� dragtype%=0 )� � 3 )�" �menu(8,!pb%-122,pb%!4+84,0) )� dragtype%=1 )� � )� � )� � (pb%!8 � 2) �grabmenu )� )� � w%(9,0) )� � (pb%!8 � 1)=0 � )� Ȏ pb%!16 � )� � 2 )� �magstring(1,0) * � 3 * �magstring(-1,0) * � 4 *& �magstring(0,1) *0 � 5 *: �magstring(0,-1) *D � *N � *X Ȏ pb%!16 � *b � 2 *l �magstring(-1,0) *v � 3 *� �magstring(1,0) *� � 4 *� �magstring(0,-1) *� � 5 *� �magstring(0,1) *� � *� � *� *� � w%(7,0) *� Ȏ pb%!16 � *� � 1 *� �savesprite *� � 0 + � (pb%!8 � &50)<>0 � + �gst(pb%,w%(7,0)) + !mb%=w%(7,0) + mb%!4=0 +*" ș "Wimp_GetIconState",,mb% +4 ilx%=mb%!8:ity%=mb%!12 +> irx%=mb%!16:iby%=mb%!20 +H �gst(mb%,w%(7,0)) +R !pb%=w%(7,0) +\ pb%!4=5 +f pb%!8=mb%!4+ilx% +p pb%!12=mb%!16+ity% +z pb%!16=mb%!4+irx% +� pb%!20=mb%!16+iby% +� pb%!24=0 +� pb%!28=0 +� pb%!32=&7FFFFFFF +� pb%!36=&7FFFFFFF +� ș "Wimp_DragBox",,pb% +� dragtype%=0 +� � +� � +� +� � w%(8,0) +� Ȏ pb%!16 � +� � 1 , �saveraw , � 0 , � (pb%!8 � &50)<>0 � ,$ �gst(pb%,w%(8,0)) ,. !mb%=w%(8,0) ,8 mb%!4=0 ,B" ș "Wimp_GetIconState",,mb% ,L ilx%=mb%!8:ity%=mb%!12 ,V irx%=mb%!16:iby%=mb%!20 ,` �gst(mb%,w%(8,0)) ,j !pb%=w%(8,0) ,t pb%!4=5 ,~ pb%!8=mb%!4+ilx% ,� pb%!12=mb%!16+ity% ,� pb%!16=mb%!4+irx% ,� pb%!20=mb%!16+iby% ,� pb%!24=0 ,� pb%!28=0 ,� pb%!32=&7FFFFFFF ,� pb%!36=&7FFFFFFF ,� ș "Wimp_DragBox",,pb% ,� dragtype%=1 ,� � ,� � ,� - � w%(1,0) - Ȏ pb%!16 � - � 7 - outmode$=" " -( � 8 -2 outmode$="C" -< � 9 -F outmode$="D" -P � 10 -Z outmode$="T" -d � 32 -n outmode$="P" -x � 25 -� ș "Wimp_CreateMenu",,-1 -� �gocfsi -� � -�? � (pb%!8 � 1) � (pb%!16<11) �iconset(1,pb%!16,1<<21,1<<21) -� -� � w%(2,0) -� adjust%=pb%!8 � 1 -� ch%=� -� Ȏ pb%!16 � -� � 1 -� � adjust% � -�, � brightness%<>0 brightness%-=1:ch%=� -� � .- � brightness%<>63 brightness%+=1:ch%=� . � .< � ch% $brightad%=�brightness%:�udpbar(-36,brightness%) ." � 2 ., � adjust% � .6- � brightness%<>63 brightness%+=1:ch%=� .@ � .J, � brightness%<>0 brightness%-=1:ch%=� .T � .^< � ch% $brightad%=�brightness%:�udpbar(-36,brightness%) .h � 6 .r � adjust% � .|( � contrast%<>0 contrast%-=1:ch%=� .� � .�) � contrast%<>63 contrast%+=1:ch%=� .� � .�6 � ch% $contad%=�contrast%:�udpbar(-80,contrast%) .� � 7 .� � adjust% � .�) � contrast%<>63 contrast%+=1:ch%=� .� � .�( � contrast%<>0 contrast%-=1:ch%=� .� � .�6 � ch% $contad%=�contrast%:�udpbar(-80,contrast%) .� � 11 .� � adjust% � /, � saturation%<>0 saturation%-=1:ch%=� / � /- � saturation%<>63 saturation%+=1:ch%=� /& � /0: � ch% $satad%=�saturation%:�udpbar(-124,saturation%) /: � 12 /D � adjust% � /N- � saturation%<>63 saturation%+=1:ch%=� /X � /b, � saturation%<>0 saturation%-=1:ch%=� /l � /v: � ch% $satad%=�saturation%:�udpbar(-124,saturation%) /� � 4 /� �palslide(pb%,-36,1) /� � 9 /� �palslide(!pb%,-80,2) /� � 14 /� �palslide(!pb%,-124,3) /� � 0 /� �setpal(0,32,32) /� � 16 /�0 �setpal(savedbright%,savedcont%,savedsat%) /� � /� /�� w%(15,0) 0 Ȏ qflag% � 0 � 1 0 Ȏ pb%!16 � 0 � 0 0*# �menu(8,!pb%-122,pb%!4+84,0) 04 dragtype%=1 0> � 2 0H �deletegrabbed 0R � 0\ � 2 0f Ȏ pb%!16 � 0p � 0 0z �shutdown(0) 0� � 2 0� � 0� � 3 0� Ȏ pb%!16 � 0� � 0 0�# �menu(7,!pb%-122,pb%!4+84,0) 0� dragtype%=0 0� � 2 0� �deletegrabbed 0� � 0� � 0� �clwin(15) 0� 1� w%(17,0) 1 Ȏ pb%!16 � 1 � 0 1$ �speedslide(!pb%) 1. � 1 18 � (pb%!8 � 1) � 1B � speed%<>0 � 1L speed%-=1 1V $speedad%=�speed% 1` �speedbar 1j � 1t � 1~ � speed%<>99 � 1� speed%+=1 1� $speedad%=�speed% 1� �speedbar 1� � 1� � 1� � 2 1� � (pb%!8 � 1) � 1� � speed%<>99 � 1� speed%+=1 1� $speedad%=�speed% 1� �speedbar 1� � 2 � 2 � speed%<>0 � 2 speed%-=1 2 $speedad%=�speed% 2( �speedbar 22 � 2< � 2F � 2P� 2Z� 2d 2n� �livemenu 2xmousex%=!pb% 2�mousey%=pb%!4 2�� bit%=12 � 2� tick12$=">" 2� cachem$=cache$ 2�� 2� tick12$="" 2� cachem$="<" 2�� 2�$� grabex% shade$="" � shade$="<" 2�"� mono$=">" � ms$="<" � ms$="" 2�Ttemp0$="FastGrab|Grab frame|'0156grabsize$'Frame size|'0156livesize$'Live size|" 2�� board_is_16_bit% � 2�� temp1$=ms$+tick12$+"16 bit data|"+ms$+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 3� 3� temp1$=tick12$+"12 bit data|"+dither$+"Dithering|"+mono$+"Monochrome|"+field$+"'0076subfield$'Single field|"+cachem$+"Force cacheing|"+shade$+"Show frame|@2'PAL decoder|'0060submode$'Grab mode|@17'V9 speed|Save choices|"+ltool$+"Toolbox|" 3� 3"%menu%=�cmenu(0,temp0$+temp1$,236) 3,mentype%=1 36� 3@ 3J� �grabmenu 3Tmousex%=!pb% 3^mousey%=pb%!4 3h � grab12% raw$="" � raw$="<" 3r^temp0$="FastGrab|@10'Sprite info|@9'Zoom|@7'Save sprite|@1'"+raw$+"ChangeFSI|@14'Credits|" 3|� board_is_16_bit% � 3�^ temp1$="@11'"+raw$+"16 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 3�� 3�^ temp1$="@11'"+raw$+"12 bit info|@8'"+raw$+"Save raw data|Delete image|"+gtool$+"Toolbox|" 3�� 3�%menu%=�cmenu(0,temp0$+temp1$,220) 3�mentype%=2 3�� 3� 3�%� �palslide(xpos%,ypos%,dragnum%) 3�!dragging%=dragnum% 3�!mb%=w%(2,0) 3�!ș "Wimp_GetWindowState",,mb% 3�mb%!24=140+mb%!4 4mb%!28=ypos%+mb%!16 4mb%!32=392+mb%!4 4mb%!36=ypos%+20+mb%!16 4&mb%!8=mb%!24 40mb%!12=mb%!28 4:mb%!16=xpos% 4Dmb%!20=mb%!36 4Nmb%!4=7 4Xș "Wimp_DragBox",,mb% 4b� 4l 4v� �udpbar(bary%,value%) 4�� value%<0 � 4�!mb%=w%(2,0) 4� mb%!4=142 4�mb%!8=bary% 4�mb%!12=394 4�mb%!16=bary%+22 4�'ș "Wimp_UpdateWindow",,mb% � more% 4�x0%=mb%!4-mb%!20 4�y0%=mb%!16-mb%!24 4�ȕ more% 4� � 4� ș "Wimp_SetColour",7 4�( ȓ Ȑ x0%+140,y0%+bary%,value%*4,20 5( ș "Wimp_GetRectangle",,mb% � more% 5� 5!mb%=w%(2,0) 5 mb%!4=84 5*mb%!8=bary%-4 54mb%!12=136 5>mb%!16=bary%+26 5H'ș "Wimp_UpdateWindow",,mb% � more% 5Rx0%=mb%!4-mb%!20 5\y0%=mb%!16-mb%!24 5fȕ more% 5p � 5z( ș "Wimp_GetRectangle",,mb% � more% 5�� 5�Ȏ bary% � 5� � -36 5� �brightness 5� � -80 5� �contrast 5� � -124 5� �saturation 5�� 5�� 5� 5�� �setpal(b%,c%,s%) 5�.brightness%=b%:contrast%=c%:saturation%=s% 6$brightad%=�(b%) 6$contad%=�(c%) 6$satad%=�(s%) 6$�udpbar(-36,b%) 6.�udpbar(-80,c%) 68�udpbar(-124,s%) 6B� 6L 6V� �calcbar(xpos%) 6`� winpos%,value% 6j!mb%=w%(2,0) 6t!ș "Wimp_GetWindowState",,mb% 6~winpos%=xpos%-mb%!4 6�=(winpos%-140)/4 6� 6�� �dopaldrag 6�!ș "Wimp_GetPointerInfo",,mb% 6�Ȏ !dragging% � 6�� 1 6� newbright%=�calcbar(!mb%) 6� � brightness%=newbright% � 6� brightness%=newbright% 6� $brightad%=�brightness% 6� �udpbar(-36,brightness%) 6�� 2 7 newcont%=�calcbar(!mb%) 7 � contrast%=newcont% � 7 contrast%=newcont% 7 $contad%=�contrast% 7( �udpbar(-80,contrast%) 72� 3 7< newsat%=�calcbar(!mb%) 7F � saturation%=newsat% � 7P saturation%=newsat% 7Z $satad%=�saturation% 7d �udpbar(-124,saturation%) 7n� 7x� 7� 7�� �speedslide(xpos%) 7�!dragging%=4 7�!mb%=w%(17,0) 7�!ș "Wimp_GetWindowState",,mb% 7�mb%!24=140+mb%!4 7�mb%!28=-36+mb%!16 7�mb%!32=338+mb%!4 7�mb%!36=-16+mb%!16 7�mb%!8=mb%!24 7�mb%!12=mb%!28 7�mb%!16=xpos% 7�mb%!20=mb%!36 8mb%!4=7 8ș "Wimp_DragBox",,mb% 8� 8" 8,� �speedbar 86� speed%<0 � 8@!mb%=w%(17,0) 8J mb%!4=142 8T mb%!8=-36 8^mb%!12=340 8hmb%!16=-14 8r'ș "Wimp_UpdateWindow",,mb% � more% 8|x0%=mb%!4-mb%!20 8�y0%=mb%!16-mb%!24 8�ȕ more% 8� � 8� ș "Wimp_SetColour",7 8�% ȓ Ȑ x0%+140,y0%-36,speed%*2,20 8�( ș "Wimp_GetRectangle",,mb% � more% 8�� 8�!mb%=w%(17,0) 8�mb%!4=84 8� mb%!8=-40 8�mb%!12=136 8�mb%!16=-10 8�'ș "Wimp_UpdateWindow",,mb% � more% 9x0%=mb%!4-mb%!20 9y0%=mb%!16-mb%!24 9ȕ more% 9& � 90( ș "Wimp_GetRectangle",,mb% � more% 9:� 9D �speed 9N� 9X� 9b 9l� �calcspeed(xpos%) 9v� winpos%,value% 9�!mb%=w%(17,0) 9�!ș "Wimp_GetWindowState",,mb% 9�winpos%=xpos%-mb%!4 9�=(winpos%-140)/2 9� 9�� �dospeeddrag 9�!ș "Wimp_GetPointerInfo",,mb% 9�newspeed%=�calcspeed(!mb%) 9�� speed%=newspeed% � 9�speed%=newspeed% 9�$speedad%=�speed% 9� �speedbar 9�� : :� �speed :!speedval=99-speed% : � :* :4� �contrast :>?IICblock%=2 :HIICblock%?1=contrast% :Rș &240,136,IICblock%,2 :\� :f :p� �saturation :z?IICblock%=1 :�IICblock%?1=saturation% :�ș &240,136,IICblock%,2 :�� :� :�� �brightness :�?IICblock%=0 :�IICblock%?1=brightness% :�ș &240,136,IICblock%,2 :�� :� :�� �chkbnds(address%) :� � �$address%=0 $address%="0" :�"� �$address%>63 $address%="63" ;� ; ;� �dragend ;$� dx%,dy%,dw%,di% ;.Ȏ !dragging% � ;8 � 1,2,3,4 ;B !dragging%=0 ;L � ;V� ;`Ȏ dragtype% � ;j � 0,1 ;t" ș "Wimp_GetPointerInfo",,mb% ;~ dx%=!mb% ;� dy%=mb%!4 ;� dw%=mb%!12 ;� di%=mb%!16 ;� Ȏ dragtype% � ;� � 0 ;� fnamelen%=�($outsprad%) ;� filesize%=spritesize%-4 ;� filetype%=&FF9 ;�* $(mb%+44)=�zt(outsprad%)+�0+�0+�0+�0 ;� � 1 ;� fnamelen%=�($outrawad%) ;� filesize%=rawsize% <