Re: QL Graphics
Posted: Fri Jan 26, 2018 12:03 pm
Back in the late 1980s I wrote this little routine in assembler which has been used in some of my programs such as Image Processor. Not infallible by any means (and doesn't use tofro's even number of flash bits suggestion). You are welcome to use or adapt this code without acknowledgement at all.
LET mode_number = GUESS(base_address,number_of_bytes)
returns 0 for mode 4, 8 for mode 8
Just takes the brute force approach of assuming that mode 8 screens contain no flashing - any flash bits set would be green bits from a mode 4 picture. Could be adapted within the DBF loop to count flash bits set to a given threshold number by statistically looking at a collectionof mode 8 screens from old games for typically how many flash bits set in mode 8 screens on average. Works adequately well for screens without any flashing as it stands. The two parameters are simply to allow for a screen anywhere in memory (not just at the video address) can be used.
In my programs I took the approach of a user confirmation - the programs said something like "I think this is mode 4, do you agree Yes/No?". Obviously you can't do this when building a list of thumbnails. What do you hope to do, an approach like Windows perhaps where the folders contain a list of thumbnails and if any images are found to change (maybe the .db or database file might contain a list of image files and their update dates and if any dates changed) update the list?
LET mode_number = GUESS(base_address,number_of_bytes)
returns 0 for mode 4, 8 for mode 8
Just takes the brute force approach of assuming that mode 8 screens contain no flashing - any flash bits set would be green bits from a mode 4 picture. Could be adapted within the DBF loop to count flash bits set to a given threshold number by statistically looking at a collectionof mode 8 screens from old games for typically how many flash bits set in mode 8 screens on average. Works adequately well for screens without any flashing as it stands. The two parameters are simply to allow for a screen anywhere in memory (not just at the video address) can be used.
In my programs I took the approach of a user confirmation - the programs said something like "I think this is mode 4, do you agree Yes/No?". Obviously you can't do this when building a list of thumbnails. What do you hope to do, an approach like Windows perhaps where the folders contain a list of thumbnails and if any images are found to change (maybe the .db or database file might contain a list of image files and their update dates and if any dates changed) update the list?
Code: Select all
* routine for Screen Compression to GUESS if a screen is mode 4 or 8
* by checking the flash bits set - in mode 8 no or very few will be set
* while in mode 4 the greens set will correspond to mode 8 flash bits
* so can be used as a reasonable guide to guessing the mode number.
* Not infallible! Mode 8 screens WITH flashing will confuse it, as will
* mode 4 screens with no green of course.
move.w $110,a0 ;bp.init
lea procblock,a1 ;procedures table
jsr (a0) ;link to basic
rts ;back to BASIC
procblock dc.w 0,0,1,entry-*
dc.b 5,'GUESS'
dc.w 0
err_rpt moveq #-15,d0 ;err.bp
rts ;back to BASIC
entry move.w $118,a0 ;ca.gtlin get long word parameters
jsr (a0)
bne.s err_rpt ;oops
subq.w #2,d3 ;exactly 2 parameters?
bne.s err_rpt ;oops
move.l 0(a6,a1.l),a0 ;base address
move.l 4(a6,a1.l),d0 ;bytes to check
lsr.w #1,d0 ;DIV 2 to convert to WORDS
subq.w #1,d0 ;prepare to DBF
loop move.w (a0)+,d1 ;word from screen
andi.w #$5500,d1 ;check flash bits
tst.w d1 ;non zero (flashing?)
bne.s mode4 ;flash bits set must be mode 4
dbf d0,loop ;any more to do?
* no flash bits set, must be mode 8
mode8 moveq #8,d0 ;prepare to return MODE 8
bra.s return ;jump to stacking part
mode4 moveq #0,d0 ;MODE 4
return moveq #3,d4 ;return word length integer
adda.l #6,a1 ;adjust RI stack pointer
move.l a1,$58(a6) ;into bv.rip
move.w d0,0(a6,a1.l) ;put mode number on stack
moveq #0,d0 ;no error
rts ;back to BASIC