*** ASSEMBLY SUCCESSFUL *** 009B ALLPSIN 0057 CHOOSE_LEFT 0060 CHOOSE_RIGHT 0069 CLEAR 00A3 COMBEGADR 000A COMMAND 008E COMMON 0003 CWADR 000B DATA 006C DGRSTR 000E DISABLE 000F ENABLE 0300 IMAGE 0039 LOAD_GRAPH 0030 NEXTCOM 0004 NUMOFC 003B NXTCOL 003D NXTPAGE 0000 PAADR 0082 PACOUTBIN 0090 PAINCOUT 0080 PANDCOUT 0001 PBADR 0002 PCADR 002B PREPARE_LCD 000D READ 0081 SENDCHAR 0082 SENDCHARA 0089 SENDCOM 008A SENDCOMA 0072 SIL 000C WRITE ;******************************************************************** ;==================================================================== ;Program:non_effic_gfx.asm ;programmer(s): Dincer Aydin ;function:Displays bitmap image on LCD ;==================================================================== ;******************************************************************** ; Example presented here require that the KS0108 cotrolled 128*64 LCD is connected to an ; 8255 with base address of 00h. ; This program was tested on a Powertip PG12864-D 128*64 Graphic LCD ; The Z80 was clocked at 2 MHz ; ; Connections: ; LCD data bus(pins #14-#7) connected to Port A of an 8255 with 00h base address ; LCD Enable pin(#6) connected to Port C bit #7 of the 8255 ; LCD R/W pin(#5) connected to Port C bit #6 of the 8255 ; LCD RS pin(#4) connected to Port C bit #5 of the 8255 ; CSA Chip selection driver 1 connected to Port C bit #4 of the 8255 ; CSB Chip selection driver 2 connected to Port C bit #3 of the 8255 ;8255 port address(base 00h): 0000 PAADR EQU 00H 0000 PBADR EQU 01H 0000 PCADR EQU 02H 0000 CWADR EQU 03H ;stuff to be written into the control word of the 8255: ;Some of the change the state of the ports and some manipulate ;bits on port C 0000 ALLPSIN EQU 9BH 0000 PAINCOUT EQU 90H 0000 PANDCOUT EQU 80H 0000 PACOUTBIN EQU 82H 0000 ENABLE EQU 0FH 0000 DISABLE EQU 0EH 0000 READ EQU 0DH 0000 WRITE EQU 0CH 0000 COMMAND EQU 0AH 0000 DATA EQU 0BH ;initialization: 0000 31 00 02 LD SP,200H ;Set stack pointer 0003 0E 03 LD C,CWADR 0005 3E 82 LD A,PACOUTBIN ;Ports A&C out,B in 0007 ED 79 OUT (C),A ;==================================================================== ;number of commands and image location: 0009 NUMOFC EQU 4H 0009 IMAGE EQU 300H ;*********it all begins here**********: 0009 CD 60 00 CALL CHOOSE_RIGHT 000C CD 2B 00 CALL PREPARE_LCD 000F CD 69 00 CALL CLEAR 0012 CD 2B 00 CALL PREPARE_LCD 0015 CD 57 00 CALL CHOOSE_LEFT 0018 CD 69 00 CALL CLEAR 001B CD 2B 00 CALL PREPARE_LCD 001E 21 00 03 LD HL,IMAGE 0021 CD 39 00 CALL LOAD_GRAPH 0024 CD 60 00 CALL CHOOSE_RIGHT 0027 CD 39 00 CALL LOAD_GRAPH 002A 76 HALT ;*********************************************** ;commands to prepare KS0108 for graphic loading ;these will set page address,display start address ;and y adress ;*********************************************** 002B 21 A3 00 PREPARE_LCD: LD HL,COMBEGADR 002E 06 04 LD B,NUMOFC 0030 CD 89 00 NEXTCOM: CALL SENDCOM 0033 23 INC HL 0034 05 DEC B 0035 C2 30 00 JP NZ,NEXTCOM 0038 C9 RET ;==================================================================== ; Subroutine name:load_graph ; programmer:Dincer Aydin ; input:HL loaded with image location ; output: ; Registers altered: many ; function:starting from (HL) will load the first 512 bayts of a bitmap ; image and will fill the half of the display (64*64 pixels) ; Statrs from the first byte of the 8th page, then the first byte of the 7th ; page, their first byte of the sixth page... and when all pages have their first ; byte each page is given its second byte and so on. ; See the animated gif on ; http://www.geocities.com/SiliconValley/Circuit/8882/lcd/gfxhowto.htm ; It demonstrates how this routine works, but It starts from page 0 ... ;=================================================================== 0039 3E 40 LOAD_GRAPH: LD A,40H ; Set Y address command 003B 06 08 NXTCOL: LD B,8 ; 003D F5 NXTPAGE: PUSH AF 003E CD 81 00 CALL SENDCHAR 0041 F1 POP AF 0042 CD 8A 00 CALL SENDCOMA ; set Y address command 0045 F5 PUSH AF 0046 3E B7 LD A,0B7H 0048 80 ADD A,B 0049 CD 8A 00 CALL SENDCOMA ; set page command 004C F1 POP AF 004D 23 INC HL 004E 10 ED DJNZ NXTPAGE 0050 3C INC A 0051 FE 80 CP 80H ; 80- 0053 C2 3B 00 JP NZ,NXTCOL 0056 C9 RET ;*********************************************** ; routine to select the left part of the display ;*********************************************** 0057 C5 CHOOSE_LEFT: PUSH BC 0058 0E 02 LD C,PCADR 005A 06 08 LD B,08H 005C ED 41 OUT (C),B 005E C1 POP BC 005F C9 RET ;*********************************************** ;routine to select the right part of the display ;*********************************************** 0060 C5 CHOOSE_RIGH: PUSH BC 0061 0E 02 LD C,PCADR 0063 06 10 LD B,10H 0065 ED 41 OUT (C),B 0067 C1 POP BC 0068 C9 RET ;*********************************** ;routine to clear the display ;*********************************** 0069 3E B8 CLEAR: LD A,0B8H 006B 5F LD E,A 006C 7B DGRSTR: LD A,E 006D 06 40 LD B,40H 006F CD 8A 00 CALL SENDCOMA 0072 3E 00 SIL: LD A,00H 0074 CD 82 00 CALL SENDCHARA 0077 10 F9 DJNZ SIL 0079 1C INC E 007A 3E C0 LD A,0C0H 007C BB CP E 007D C2 6C 00 JP NZ,DGRSTR 0080 C9 RET ;==================================================================== ; Subroutine name:sendcomA & sendcom & sendcharA & sendchar ; programmer:Caner Buyuktuna & Dincer Aydin ; input:A or (HL) ; output: ; Registers altered:A ; function: sendcharA sends the data in A to the LCD ; sendchar sends the data in (HL) to the LCD ; sendcomA sends the command in A to the LCD ; sendcom sends the command in (HL) to the LCD ; !!!!!!!!!!- The busy flag is not checked -!!!!!!!!!! ;==================================================================== 0081 7E SENDCHAR: LD A,(HL) ; put the data to be sent to the LCD in A 0082 C5 SENDCHARA: PUSH BC ; save BC 0083 D5 PUSH DE ; save DE 0084 1E 0B LD E,DATA 0086 C3 8E 00 JP COMMON 0089 7E SENDCOM: LD A,(HL) 008A C5 SENDCOMA: PUSH BC ; save BC 008B D5 PUSH DE ; save DE 008C 1E 0A LD E,COMMAND 008E 0E 03 COMMON: LD C,CWADR 0090 ED 59 OUT (C),E ; Set/reset RS accoring to the content of register E 0092 16 0C LD D,WRITE 0094 ED 51 OUT (C),D ; reset RW pin for writing to LCD 0096 D3 00 OUT (PAADR),A ; place data/instrucrtion to be written into portA 0098 16 0F LD D,ENABLE 009A ED 51 OUT (C),D ; enable the LCD 009C 16 0E LD D,DISABLE 009E ED 51 OUT (C),D ; disable the LCD 00A0 D1 POP DE ; restore DE 00A1 C1 POP BC ; restore BC 00A2 C9 RET ; return 00A3 3F 40 B8 C0 COMBEGADR: DB 3FH,40H,0B8H,0C0H