Re: A89: 7-level Grayscale


[Prev][Next][Index][Thread]

Re: A89: 7-level Grayscale




According to Miles Raymond:
> 
> 
> 
> Can someone try to help me understand grayscale (greyscale?) with the =
> attached file??  I've been trying at this simple program all day...
> 
> -Miles Raymond      EML: m_rayman@bigfoot.com
> ICQ: 13217756       IRC: Killer2        AIM: MRayMan
> http://www.bigfoot.com/~m_rayman/
> 
> 	include "doorsos.h"
> 	include "graphlib.h"
> 	include "userlib.h"
> 	xdef    _ti89
> 	xdef    _comment
> 	xdef    _main
> _main:
> 	jsr	graphlib::gray7		;switches to 7 grayscale mode
> 	move.w	#1,graphlib::choosescreen	;set all graphlib functions to =
> grayscale
> 
> 	move.l	graphlib::plane0,a1	;address of the 1st bitplane (plane0)
> 	jsr	graphlib::clr_scr	;clears the first bitplane (main screen)
> 	move.l	graphlib::plane1,a1	;address of the 2nd bitplane (plane1)
> 	jsr	graphlib::clr_scr	;clears the second bitplane
> 	move.l	graphlib::plane2,a1	;address of the 3rd bitplane (plane2)
> 	jsr	graphlib::clr_scr	;clears the third bitplane
> 
> 	move.l	graphlib::plane0,a0	;address of the 1st bitplane
> 	lea	1500(a0),a0		;50th line (50 * 30 =3D 1500)
> 	move.w	#374,d0			;why 374???
> \loop1	move.l	#$FFFFFFFF,(a0)+	;why #$FFFFFFFF and not #$FFFF?
> 	dbra	d0,\loop1		;374 times?  why?

it's a loop that execute 375 times (374 to 0 included) :
  move.l #$FFFFFFFF,(a0)+

  Each loop execution write 4 bytes in the memory at location a0 (it
write a long, then 4 bytes). That's why there is $FFFFFFFF,
$FFFF is a word (as you see after, with move.w $FFFF,(a0)+ ).
  Then after the loop it will write 1750 bytes (approx 58 lines,
each line is 30 bytes).
  Be careful !! Screen size in the memory is 240x128 (TI92 size)
but only a screen of 160x100 is drawn !! (there is unused bytes,
10 bytes for each lines, at the end of the memory screen, there
is 28 unused lines (28x30 bytes)).

  Then this loop write out of TI89 screen, put instead :
  move.w #$FFFF,(a0)+

  But it's wrong for a TI89 ...
  Tell me if you want a correct routine

> 
> 	move.l	graphlib::plane1,a0	;address of the 2nd bitplane
> 	lea	750(a0),a0		;25th line (25 * 30 =3D 750)
> 	move.w	#374,d0
> \loop2	move.w	#$FFFF,(a0)+		;put black over the next 25 lines
> 	dbra	d0,\loop2
> 
> 	move.l	graphlib::plane1,a0	;address of the 2nd bitplane
> 	lea	2250(a0),a0		;75th line (75 * 30 =3D 2250)
> 	move.w	#374,d0
> \loop3	move.w	#$FFFF,(a0)+		;put black over the next 25 lines
> 	dbra	d0,\loop3
> 
> ;leaving this out is the only way that this program will actually run on =
> my 89... =3D(
> 
> ;	move.l	graphlib::plane2,a0	;address of the 3rd bitplane
> ;	lea	360(a0),a0		;12th line (12 * 30 =3D 360)
> ;	move.w	#374,d0
> ;\loop4	move.w	#$FFFF,(a0)+		;put black over the next 12 lines
> ;	dbra	d0,\loop4
> 
> ;	move.l	graphlib::plane2,a0	;address of the 3rd bitplane
> ;	lea	1110(a0),a0		;37th line (37 * 30 =3D 1110)
> ;	move.w	#374,d0
> ;\loop5	move.w	#$FFFF,(a0)+		;put black over the next 12 lines
> ;	dbra	d0,\loop5
> 
> ;	move.l	graphlib::plane2,a0	;address of the 3rd bitplane
> ;	lea	1860(a0),a0		;62th line (62 * 30 =3D 1860)
> ;	move.w	#374,d0
> ;\loop6	move.w	#$FFFF,(a0)+		;put black over the next 12 lines
> ;	dbra	d0,\loop6
> 
> ;	move.l	graphlib::plane2,a0	;address of the 3rd bitplane
> ;	lea	2610(a0),a0		;87th line (87 * 30 =3D 2610)
> ;	move.w	#374,d0
> ;\loop7	move.w	#$FFFF,(a0)+		;put black over the next 12 lines
> ;	dbra	d0,\loop7

  Again is for TI92, it does not write 12 lines ... It's out of screen
(but don't crash :( )

> 
> 					;so we get:
> 					;25 lines : white
> 					;25 lines : low gray
> 					;25 lines : dark gray
> 					;25 lines : black
> 
> 	clr.w	graphlib::choosescreen	;set all graphlib functions to Black and =
> White mode
> 	jsr	userlib::idle_loop	;waits for a key
> 	jsr	graphlib::gray2		;restores Black and White mode
> 	rts
> 
> 
> _comment   dc.b    "Gray4 test",0
>         end


CandyMan

http://www.i-france.com/candyman
candyman@I-france.com


References: