;--------------------------------------------------------------------------- ;***** GreyLib version 1.0 (C) 1997 by Bill Nagel & Dines Justesen ********* ;--------------------------------------------------------------------------- ; This a greyscale library for the TI83, which supports both 4 and 8 shades ; of grey. Below is a short definition of what the library needs, and which ; function it includes. For an example of how to use the library see ; Grey.asm. ; ; Because the TI83 uses a display controller and not a memory mapped display ; like the ti85, greyscale on the TI83 is alot slower. Therefore the grey- ; scale pictures does notlooks as good as on the TI85. But have a look at ; what you can do, and see if you like it anyway. ; ; You are welcome to use this library in your own program as long as you ; give us the credit. Just on line mentioning our names and that ; the routine came from GreyLib, that is all. ; ;--------------------------------------------------------------------------- ; Definitions used: ; USE_8_SHADES : If defined the uses three pictures to make 8 shades of ; grey. Otherwise it use two pictures to make 4 shades. ; USE_85_PIC : If defined the library uses pictures in the format used ; by the TI85. This is included show pictures made for TI85 ; programs can be view without problems. ; CHECK_VBI : Normally the display is updated on every interrupt, but if ; CHECK_VBI is defined it will only by updated on VBI inter- ; rupts. ; FAST_UPDATE : Because the TI83 uses a display controller, greyscale is ; not very fast, therefor the display is normally only up- ; dated on every 2nd/4th interrupt. If FAST_UPDATE is ; defined the display will be updated on every /every 2nd ; interrupt. ;---------------------------------------------------------------------------- GreyScaleOn: LD HL,$8300 LD DE,$8301 LD BC,256 LD (HL),$85 LDIR LD HL,IntProcStart ; Get pointer to interrupt rutine LD DE,$8585 ; Start of int rutine, and length of it LD BC,IntProcEnd-IntProcStart+1 LDIR XOR A ; Init vars LD ($8583),A LD A,$83 ; Point to the new table LD I,A IM 2 RET GreyScaleOff: IM 1 ; Normal interrupt mode SET 0,(IY+3) ; Graph is dirty RET IntProcStart: EX AF,AF' EXX #IFDEF CHECK_VBI IN A,(3) BIT 1,A JR Z,ExitInt #ENDIF LD HL,$8583 INC (HL) LD A,(HL) #IFDEF USE_8_SHADES CP $7 ; If Counter=6 then display picture 3 JR Z,Display_pic3 CP $5 JR Z,Display_pic2 ; If Counter=4 then display picture 2 CP $1 JR Z,Display_pic1 ; If Counter=1 then display picture 1 ; Counter : 1 2 3 4 5 6 7 ; Picture : 1 1 1 1 2 2 3 #ELSE CP $1 ; If Counter=1 then display picture 1 JR Z,Display_pic1 #IFNDEF FAST_UPDATE CP $4 ; If Counter=4 then display picture 2 JR Z,Display_pic2 JR C,ExitInt ; If Counter=5 then reset counter ; Counter : 1 2 3 4 5 ; Picture : 1 1 1 2 2 XOR A LD ($8583),A #ELSE CP $3 JR Z,Display_pic2 #ENDIF #ENDIF ExitInt: EXX EX AF,AF' JP $0038 ; Call Std interrupt handler Display_pic1: LD HL,Graypic_bit1 JR DisplayPicture Display_pic2: #IFDEF FAST_UPDATE #IFNDEF USE_8_SHADES XOR A LD ($8583),A #ENDIF #ENDIF LD HL,Graypic_bit2 JR DisplayPicture #IFDEF USE_8_SHADES Display_pic3: XOR A LD ($8583),A LD HL,Graypic_bit3 JR DisplayPicture #ENDIF DisplayPicture: LD A, 7 CALL LCDBusy OUT ($10),A ;send 00000111 to LCD : select row number LD A,$80 ; Goto the left LineLoop: LD D,A ; Save currect coloum CALL LCDBusy OUT ($10),A LD A,$20 ; Goto top CALL LCDBusy OUT ($10),A LD BC,$0C11 ; 40 bytes to port 10 WriteLoop: ; Write them NEG NEG NEG NEG OUTI JR NZ,WriteLoop #IFDEF USE_85_PIC INC HL INC HL INC HL INC HL #ENDIF LD A,D INC A CP $C0 JR NZ,LineLoop JR ExitInt LCDBusy: PUSH AF ;This is the TI made procedure INC HL ;it makes a small pause before DEC HL ;writing to the LCD POP AF RET IntProcEnd: .END