A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     1


MACRO ASSEMBLER A51 V6.02
OBJECT MODULE PLACED IN .\text_graphics_routines.OBJ
ASSEMBLER INVOKED BY: E:\Brno\zaloha\disk_C\ATMEL\C51\Keil6\C51\BIN\A51.EXE .\text_graphics_routines.a51 SET(SMALL) DEBU
                      G EP

LOC  OBJ            LINE     SOURCE

                       1             NAME txt_graph
                       2     
                       3     ;******************************************************************************************
                             ************
                       4     ;******************************************************************************************
                             ************
                       5     ;       texts routines
                       6     ;******************************************************************************************
                             ************
                       7     ;******************************************************************************************
                             ************
                       8     ;==========================================================================================
                             ============ 
                       9     ;       draw XRAM string form strtmp
                      10     ;==========================================================================================
                             ============ 
                      11     ?PR?_DrawStrXRAM?txt_graph SEGMENT CODE
----                  12             RSEG    ?PR?_DrawStrXRAM?txt_graph
                      13     
                      14             USING   0       
                      15     
                      16             PUBLIC _DrawStrXRAM
                      17             EXTRN code (FontList)
                      18             EXTRN data (xpos)
                      19             EXTRN data (ypos)
                      20             EXTRN xdata (img0)
                      21             EXTRN xdata (strtmp)
                      22     
  00A2                23     AUXR1   DATA    0A2h
                      24     
0000 E500     F       25     _DrawStrXRAM:   mov     a,xpos
0002 C3               26             clr     c
0003 94F0             27             subb    a,#240
0005 4003             28             jc      $+5
0007 020000   F       29             ljmp    LCDwrTxtD       ;exit if xpos out of screen
                      30     
000A C007             31             push    AR7
000C ED               32             mov     a,R5
000D 20E106           33             jb      acc.1,DrawStrXRAMNI
0010 ED               34             mov     a,R5
0011 7003             35             jnz     $+5
0013 120000   F       36             lcall   DrawStrBck      ;draw black squere if needed
0016 D007             37     DrawStrXRAMNI:  pop     AR7
                      38             
0018 EF               39             mov     a,R7
0019 75F003           40             mov     b,#3
001C A4               41             mul     ab
001D 2400     F       42             add     a,#low(FontList)
001F F582             43             mov     dpl,a
0021 E4               44             clr     a
0022 3400     F       45             addc    a,#high(FontList)
0024 F583             46             mov     dph,a
0026 E4               47             clr     a
0027 93               48             movc    a,@a+dptr
0028 FD               49             mov     R5,a
0029 7401             50             mov     a,#1
002B 93               51             movc    a,@a+dptr
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     2

002C FE               52             mov     R6,a    ;font pointer
002D 7402             53             mov     a,#2
002F 93               54             movc    a,@a+dptr
0030 FC               55             mov     R4,a    ;font heigth
0031 2500     F       56             add     a,ypos
0033 30E703           57             jnb     acc.7,$+6
0036 020000   F       58             ljmp    LCDwrTxtD       ;exit if ypos out of screen
                      59             
0039 900000   F       60             mov     dptr,#strtmp    ;string pointer
                      61     
003C                  62     LCDwrTxt:       ;get string char
003C E0               63             movx    a,@dptr
003D A3               64             inc     dptr
003E 7003             65             jnz     LCDwrTxtDN
0040 020000   F       66             ljmp    LCDwrTxtD
0043 C082             67     LCDwrTxtDN:     push    dpl
0045 C083             68             push    dph
                      69             ;get pointer character pointer data from CP1250 table
0047 75F002           70             mov     b,#2
004A A4               71             mul     ab
004B 2E               72             add     a,R6
004C F582             73             mov     dpl,a
004E E5F0             74             mov     a,b
0050 3D               75             addc    a,R5
0051 F583             76             mov     dph,a
0053 7401             77             mov     a,#1
0055 93               78             movc    a,@a+dptr
0056 F5F0             79             mov     b,a
0058 7400             80             mov     a,#0
005A 93               81             movc    a,@a+dptr
005B 85F082           82             mov     dpl,b
005E F583             83             mov     dph,a
                      84             ;draw character image
0060 7400             85             mov     a,#0
0062 93               86             movc    a,@a+dptr
0063 A3               87             inc     dptr
0064 FF               88             mov     R7,a    ;store char x len
                      89     
0065 8500F0   F       90             mov     b,xpos  ;initial xpos for new char
0068 53F007           91             anl     b,#00000111b
006B 7401             92             mov     a,#00000001b
006D 30F102           93             jnb     b.1,$+5
0070 7404             94             mov     a,#00000100b
0072 30F001           95             jnb     b.0,$+4
0075 23               96             rl      a
0076 30F201           97             jnb     b.2,$+4
0079 C4               98             swap    a
007A F9               99             mov     R1,a    ;horizontal offset multiplier (2^offset)
                     100             ;
007B 05A2            101             inc     auxr1
                     102             ;
007D E500     F      103             mov     a,xpos
007F 03              104             rr      a
0080 03              105             rr      a
0081 03              106             rr      a
0082 541F            107             anl     a,#00011111b
0084 2400     F      108             add     a,#low(img0)
0086 F583            109             mov     dph,a   ;## swapped for optimalization
0088 7400     F      110             mov     a,#high(img0)
008A 3400            111             addc    a,#0
008C F582            112             mov     dpl,a   ;## swapped for optimalization
008E 741E            113             mov     a,#30
0090 8500F0   F      114             mov     b,ypos
0093 A4              115             mul     ab
0094 2583            116             add     a,dph
0096 C582            117             xch     a,dpl
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     3

0098 35F0            118             addc    a,b
009A F583            119             mov     dph,a
                     120             ;
009C 05A2            121             inc     auxr1
                     122     
009E 0F              123             inc     R7
009F E500     F      124             mov     a,xpos
00A1 2F              125             add     a,R7
00A2 F500     F      126             mov     xpos,a  ;new text x len (in pixels)
00A4 4005            127             jc      LCDwrTxtNL
00A6 C3              128             clr     c
00A7 94F0            129             subb    a,#240
00A9 4024            130             jc      LCDwrTxtNNL
                     131             ;xpos over 239, break line
00AB E500     F      132     LCDwrTxtNL:     mov     a,ypos
00AD 2C              133             add     a,R4    ;add font heigth to ypos
00AE F500     F      134             mov     ypos,a
00B0 20E744          135             jb      acc.7,LCDwrTxtDC        ;exit routine if line over LCD
00B3 05A2            136             inc     auxr1
00B5 75F01E          137             mov     b,#30
00B8 A4              138             mul     ab
00B9 2400     F      139             add     a,#low(img0)
00BB F582            140             mov     dpl,a
00BD 7400     F      141             mov     a,#high(img0)
00BF 35F0            142             addc    a,b
00C1 F583            143             mov     dph,a   ;new img0 pointer offsett
00C3 05A2            144             inc     auxr1
00C5 E500     F      145             mov     a,ypos
00C7 2C              146             add     a,R4
00C8 20E72C          147             jb      acc.7,LCDwrTxtDC        ;exit routine if line over LCD
00CB 8F00     F      148             mov     xpos,R7 ;xpos = char width + 1
00CD 7901            149             mov     R1,#1   ;horizontal offset multiplier (2^offset)
00CF                 150     LCDwrTxtNNL:    
                     151             
00CF EC              152             mov     a,R4
00D0 FF              153             mov     R7,a
00D1 E4              154     LCDwrTxtL1:     clr     a
00D2 93              155             movc    a,@a+dptr
00D3 89F0            156             mov     b,R1
00D5 A4              157             mul     ab
00D6 F8              158             mov     R0,a
00D7 A3              159             inc     dptr
00D8 05A2            160             inc     auxr1
00DA E0              161             movx    a,@dptr
00DB 68              162             xrl     a,R0    ;xor low part of character word
00DC F0              163             movx    @dptr,a
00DD A3              164             inc     dptr
00DE E0              165             movx    a,@dptr
00DF 65F0            166             xrl     a,b     ;xor high part of character word
00E1 F0              167             movx    @dptr,a
00E2 E582            168             mov     a,dpl   ;move pointer to next line
00E4 241D            169             add     a,#low(30-1)
00E6 F582            170             mov     dpl,a
00E8 5002            171             jnc     LCDwrTxtL1S1
00EA 0583            172             inc     dph
00EC 05A2            173     LCDwrTxtL1S1:   inc     auxr1
00EE DFE1            174             djnz    R7,LCDwrTxtL1   
                     175             ;add space
00F0 D083            176             pop     dph
00F2 D082            177             pop     dpl
00F4 020000   F      178             jmp     LCDwrTxt
00F7 D083            179     LCDwrTxtDC:     pop     dph
00F9 D082            180             pop     dpl
00FB 22              181     LCDwrTxtD:      ret     
                     182     
                     183     ;==========================================================================================
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     4

                             ============ 
                     184     ;       draw string black background
                     185     ;==========================================================================================
                             ============ 
                     186     ?PR?_DrawStrBck?txt_graph SEGMENT CODE
----                 187             RSEG    ?PR?_DrawStrBck?txt_graph
                     188     
                     189             USING   0       
                     190     
0000 EF              191     DrawStrBck:     mov     a,R7
0001 75F003          192             mov     b,#3
0004 A4              193             mul     ab
0005 2400     F      194             add     a,#low(FontList)
0007 F582            195             mov     dpl,a
0009 E4              196             clr     a
000A 3400     F      197             addc    a,#high(FontList)
000C F583            198             mov     dph,a
000E E4              199             clr     a
000F 93              200             movc    a,@a+dptr
0010 FD              201             mov     R5,a
0011 7401            202             mov     a,#1
0013 93              203             movc    a,@a+dptr
0014 FE              204             mov     R6,a    ;font pointer
0015 7402            205             mov     a,#2
0017 93              206             movc    a,@a+dptr
0018 FF              207             mov     R7,a    ;font heigth
0019 2500     F      208             add     a,ypos
001B 04              209             inc     a
001C 30E703          210             jnb     acc.7,$+6
001F 020000   F      211             ljmp    DrawStrBckDE    ;exit if ypos out of screen
                     212     
0022 7903            213             mov     R1,#3   ;string len in pixels
                     214             
0024 900000   F      215             mov     dptr,#strtmp    ;string pointer
0027                 216     DrawStrBckLL:   ;get string char
0027 E0              217             movx    a,@dptr
0028 A3              218             inc     dptr
0029 602A            219             jz      DrawStrBckD
002B C082            220             push    dpl
002D C083            221             push    dph
                     222             ;get pointer character pointer data from CP1250 table
002F 75F002          223             mov     b,#2
0032 A4              224             mul     ab
0033 2E              225             add     a,R6
0034 F582            226             mov     dpl,a
0036 E5F0            227             mov     a,b
0038 3D              228             addc    a,R5
0039 F583            229             mov     dph,a
003B 7401            230             mov     a,#1
003D 93              231             movc    a,@a+dptr
003E F5F0            232             mov     b,a
0040 7400            233             mov     a,#0
0042 93              234             movc    a,@a+dptr
0043 85F082          235             mov     dpl,b
0046 F583            236             mov     dph,a
                     237             ;draw character image
0048 7400            238             mov     a,#0
004A 93              239             movc    a,@a+dptr
004B A3              240             inc     dptr
004C 29              241             add     a,R1    ;add new char len to str len in pixels
004D 04              242             inc     a
004E F9              243             mov     R1,a
004F D083            244             pop     dph
0051 D082            245             pop     dpl
0053 80D2            246             sjmp    DrawStrBckLL
                     247     
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     5

0055 E500     F      248     DrawStrBckD:    mov     a,xpos
0057 24FE            249             add     a,#-2
0059 29              250             add     a,R1
005A 407F            251             jc      DrawStrBckDE    ;skip if x out of range
005C C3              252             clr     c
005D 94F0            253             subb    a,#240
005F 507A            254             jnc     DrawStrBckDE    ;skip if x out of range                                    
                                  
                     255     
0061 741E            256             mov     a,#30
0063 8500F0   F      257             mov     b,ypos
0066 A4              258             mul     ab
0067 2400     F      259             add     a,#low(img0)
0069 F582            260             mov     dpl,a
006B 7400     F      261             mov     a,#high(img0)
006D 35F0            262             addc    a,b
006F F583            263             mov     dph,a   ;pointer to the tol left corner of the squere
                     264             
                     265             ;draw black filled squere
0071 E500     F      266             mov     a,xpos
0073 24FE            267             add     a,#-2
0075 F8              268             mov     R0,a
0076 C3              269             clr     c
0077 94F0            270             subb    a,#240
0079 5060            271             jnc     DrawStrBckDE    ;skip if x out of range
007B E8              272             mov     a,R0
007C 75F008          273             mov     b,#8
007F 84              274             div     ab
0080 FB              275             mov     R3,a
0081 7401            276             mov     a,#00000001b
0083 30F102          277             jnb     b.1,$+5
0086 7404            278             mov     a,#00000100b
0088 30F001          279             jnb     b.0,$+4
008B 33              280             rlc     a
008C 30F201          281             jnb     b.2,$+4
008F C4              282             swap    a
0090 FA              283             mov     R2,a
                     284     
0091 E582            285             mov     a,dpl
0093 2B              286             add     a,R3
0094 F582            287             mov     dpl,a
0096 E583            288             mov     a,dph
0098 3400            289             addc    a,#0
009A F583            290             mov     dph,a
                     291     
009C 0F              292             inc     R7
009D AB01            293             mov     R3,AR1
009F                 294     DrawStrBckDL:   
009F AC82            295             mov     R4,dpl
00A1 AD83            296             mov     R5,dph
00A3 AE07            297             mov     R6,AR7
                     298             
00A5 E9              299             mov     a,R1
00A6 C3              300             clr     c
00A7 9401            301             subb    a,#1
00A9 6004            302             jz      DrawStrBckNFL
00AB EB              303             mov     a,R3
00AC B5010E          304             cjne    a,AR1,DrawStrBckDFL
                     305             ;first and last column
00AF E582            306     DrawStrBckNFL:  mov     a,dpl
00B1 241E            307             add     a,#low(30)
00B3 F582            308             mov     dpl,a
00B5 E583            309             mov     a,dph
00B7 3400            310             addc    a,#high(30)
00B9 F583            311             mov     dph,a
00BB 1E              312             dec     R6
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     6

00BC 1E              313             dec     R6
                     314     
00BD E0              315     DrawStrBckDFL:  movx    a,@dptr
00BE 4A              316             orl     a,R2
00BF F0              317             movx    @dptr,a
00C0 E582            318             mov     a,dpl
00C2 241E            319             add     a,#low(30)
00C4 F582            320             mov     dpl,a
00C6 E583            321             mov     a,dph
00C8 3400            322             addc    a,#high(30)
00CA F583            323             mov     dph,a
00CC DEEF            324             djnz    R6,DrawStrBckDFL
00CE 8C82            325             mov     dpl,R4
00D0 8D83            326             mov     dph,R5
00D2 EA              327             mov     a,R2
00D3 23              328             rl      a
00D4 FA              329             mov     R2,a
00D5 30E001          330             jnb     acc.0,DrawStrBckDS
00D8 A3              331             inc     dptr
00D9 D9C4            332     DrawStrBckDS:   djnz    R1,DrawStrBckDL
                     333     
                     334     
                     335     
                     336     
                     337     
                     338     
                     339     
                     340     
                     341     
                     342     
                     343     
                     344     
                     345     
                     346     
                     347     
                     348     
                     349     
                     350     
                     351     
                     352     
                     353     
                     354     
                     355     
                     356     
                     357     
                     358     
                     359     
                     360     
                     361     
                     362     
                     363     
                     364     
                     365     
                     366     
                     367     
                     368     
                     369     
                     370     
                     371     
                     372     
                     373     
                     374     
                     375     
                     376     
                     377     
                     378     
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     7

                     379     
                     380     
                     381     
                     382     
                     383     
                     384     
                     385     
                     386     
                     387     
                     388     
                     389     
                     390     
                     391     
                     392     
                     393     
                     394     
                     395     
                     396     
                     397     
                     398     
                     399     
00DB 22              400     DrawStrBckDE:   ret
                     401     
                     402     
                     403     
                     404     
                     405     ;******************************************************************************************
                             ************
                     406     ;******************************************************************************************
                             ************
                     407     ;       graphics routines
                     408     ;******************************************************************************************
                             ************
                     409     ;******************************************************************************************
                             ************
                     410     ;==========================================================================================
                             ============ 
                     411     ;       draw line
                     412     ;==========================================================================================
                             ============ 
                     413     ?PR?_DrawLine?txt_graph SEGMENT CODE
                     414     ?DT?_DrawLine?txt_graph SEGMENT DATA
                     415             PUBLIC  _DrawLine
                     416             PUBLIC  ?_DrawLine?BYTE
                     417     
----                 418             RSEG    ?DT?_DrawLine?txt_graph
0000                 419     ?_DrawLine?BYTE:        ds      4
                     420     
----                 421             RSEG    ?PR?_DrawLine?txt_graph
                     422     
                     423             ;R7:Ax
                     424             ;R5:Ay
                     425             ;R3:Bx
                     426     
0000 EF              427     _DrawLine:      mov     a,R7
0001 FA              428             mov     R2,a    ;Ax
0002 C3              429             clr     c
0003 94F0            430             subb    a,#240
0005 4001            431             jc      $+3
0007 22              432             ret
0008 EB              433             mov     a,R3
0009 FC              434             mov     R4,a    ;Bx
000A C3              435             clr     c
000B 94F0            436             subb    a,#240
000D 4001            437             jc      $+3
000F 22              438             ret
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     8

0010 ED              439             mov     a,R5
0011 FB              440             mov     R3,a    ;Ay
0012 30E701          441             jnb     acc.7,$+4
0015 22              442             ret
0016 E500     F      443             mov     a,?_DrawLine?BYTE+3
0018 FD              444             mov     R5,a    ;By
0019 30E701          445             jnb     acc.7,$+4
001C 22              446             ret
                     447             
                     448     ;       mov     a,R7
                     449     ;       mov     R3,a
                     450     ;       mov     a,R6
                     451     ;       mov     R2,a
                     452     
001D EC              453             mov     a,R4
001E C3              454             clr     c
001F 9A              455             subb    a,R2
0020 FE              456             mov     R6,a    ;dx or -dx
0021 500A            457             jnc     DrawLineQC
                     458             ;swap A and B because Ax must be lower than Bx
0023 EA              459             mov     a,R2
0024 CC              460             xch     a,R4
0025 FA              461             mov     R2,a
0026 EB              462             mov     a,R3
0027 CD              463             xch     a,R5
0028 FB              464             mov     R3,a
0029 EE              465             mov     a,R6
002A F4              466             cpl     a
002B 04              467             inc     a
002C FE              468             mov     R6,a    ;dx
                     469             ;Ax > Bx
002D                 470     DrawLineQC:     
                     471             ;calculate A point img pointer and mask
002D EA              472             mov     a,R2
002E 75F008          473             mov     b,#8
0031 84              474             div     ab
0032 C0F0            475             push    b       ;push pixel offset
0034 2400     F      476             add     a,#low(img0)
0036 F583            477             mov     dph,a   ;## swapped for optimalizaition
0038 7400            478             mov     a,#0
003A 3400     F      479             addc    a,#high(img0)
003C F582            480             mov     dpl,a   ;## swapped for optimalizaition
003E EB              481             mov     a,R3
003F 75F01E          482             mov     b,#30
0042 A4              483             mul     ab
0043 2583            484             add     a,dph
0045 C582            485             xch     a,dpl
0047 35F0            486             addc    a,b
0049 F583            487             mov     dph,a   ;initial byte pointer
                     488             ;convert bit offset to bit mask
004B D0F0            489             pop     b
004D 7401            490             mov     a,#00000001b
004F 30F102          491             jnb     b.1,DrawLineO2M1
0052 7404            492             mov     a,#00000100b
0054 30F201          493     DrawLineO2M1:   jnb     b.2,DrawLineO2M2
0057 C4              494             swap    a
0058 30F001          495     DrawLineO2M2:   jnb     b.0,DrawLineO2M3
005B 23              496             rl      a
005C F5F0            497     DrawLineO2M3:   mov     b,a
                     498             ;which quartal?
005E ED              499             mov     a,R5
005F C3              500             clr     c
0060 9B              501             subb    a,R3
0061 405C            502             jc      DrawLineQ4      ;IV.Q
                     503             ;I.Q (By >= Ay)
0063 FF              504             mov     R7,a    ;dy
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE     9

0064 C3              505             clr     c
0065 9E              506             subb    a,R6
0066 402C            507             jc      DrawLineQ1X     ;dx > dy
                     508             ;======= dy >= dx =======
0068 EF              509             mov     a,R7
0069 F8              510             mov     R0,a    ;initial temp=dy
006A 04              511             inc     a
006B FF              512             mov     R7,a    ;(dy+1) used for loop counter
006C FD              513             mov     R5,a    ;(dy+1)
006D 0E              514             inc     R6      ;(dx+1)
                     515             ;
006E E0              516     DrawLineQ1YL1:  movx    a,@dptr
006F 45F0            517             orl     a,b     ;add pixel into image
0071 F0              518             movx    @dptr,a
0072 E8              519             mov     a,R0
0073 C3              520             clr     c
0074 9E              521             subb    a,R6    ;temp-=(dx+1)
0075 F8              522             mov     R0,a
0076 500B            523             jnc     DrawLineQ1YS1
                     524             ;temp < 0
0078 2D              525             add     a,R5    ;temp+=(dy+1)
0079 F8              526             mov     R0,a
                     527             ;now x++
007A E5F0            528             mov     a,b     ;load bit mask
007C 23              529             rl      a       ;rotate bit (x++)
007D F5F0            530             mov     b,a     ;store it back
007F 30F001          531             jnb     b.0,DrawLineQ1YS1
0082 A3              532             inc     dptr    ;mask out of range, dptr++ (move to next byte, mask reseted back to
                              00000001b)
0083                 533     DrawLineQ1YS1:  ;now we have to make y++ step
0083 E582            534             mov     a,dpl
0085 241E            535             add     a,#low(30)
0087 F582            536             mov     dpl,a
0089 E583            537             mov     a,dph
008B 3400            538             addc    a,#high(30)
008D F583            539             mov     dph,a   ;dptr+=xres
008F DFDD            540             djnz    R7,DrawLineQ1YL1        ;next pixel?
                     541             ;done - hell yeah
0091 020000   F      542             jmp     DrawLineDone
                     543             ;======= dx > dy =======
0094 EE              544     DrawLineQ1X:    mov     a,R6
0095 F8              545             mov     R0,a    ;initial temp=dx
0096 04              546             inc     a
0097 FE              547             mov     R6,a    ;(dx+1) used for loop counter
0098 FD              548             mov     R5,a    ;(dx+1)
0099 0F              549             inc     R7      ;(dy+1)
                     550             ;
009A E0              551     DrawLineQ1XL1:  movx    a,@dptr
009B 45F0            552             orl     a,b     ;add pixel into image
009D F0              553             movx    @dptr,a
009E E8              554             mov     a,R0
009F C3              555             clr     c
00A0 9F              556             subb    a,R7    ;temp-=(dy+1)
00A1 F8              557             mov     R0,a
00A2 500E            558             jnc     DrawLineQ1XS1
                     559             ;temp < 0
00A4 2D              560             add     a,R5    ;temp+=(dx+1)
00A5 F8              561             mov     R0,a
                     562             ;now y++
00A6 E582            563             mov     a,dpl
00A8 241E            564             add     a,#low(30)
00AA F582            565             mov     dpl,a
00AC E583            566             mov     a,dph
00AE 3400            567             addc    a,#high(30)
00B0 F583            568             mov     dph,a   ;dptr+=xres
00B2                 569     DrawLineQ1XS1:  ;now we have to make x++ step
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE    10

00B2 E5F0            570             mov     a,b     ;load bit mask
00B4 23              571             rl      a       ;rotate bit (x++)
00B5 F5F0            572             mov     b,a     ;store it back
00B7 30F001          573             jnb     b.0,DrawLineQ1XS2
00BA A3              574             inc     dptr    ;mask out of range, dptr++ (move to next byte, mask reseted back to
                              00000001b)
00BB DEDD            575     DrawLineQ1XS2:  djnz    R6,DrawLineQ1XL1        ;next pixel?
                     576             ;done - hell yeah
00BD 805B            577             sjmp    DrawLineDone
                     578             
                     579             ;IV.Q (Ay > By)
00BF F4              580     DrawLineQ4:     cpl     a
00C0 04              581             inc     a
00C1 FF              582             mov     R7,a    ;dy
00C2 C3              583             clr     c
00C3 9E              584             subb    a,R6
00C4 402B            585             jc      DrawLineQ4X     ;dx > dy
                     586             ;======= dy >= dx =======
00C6 EF              587             mov     a,R7
00C7 F8              588             mov     R0,a    ;initial temp=dy
00C8 04              589             inc     a
00C9 FF              590             mov     R7,a    ;(dy+1) used for loop counter
00CA FD              591             mov     R5,a    ;(dy+1)
00CB 0E              592             inc     R6      ;(dx+1)
                     593             ;
00CC E0              594     DrawLineQ4YL1:  movx    a,@dptr
00CD 45F0            595             orl     a,b     ;add pixel into image
00CF F0              596             movx    @dptr,a
00D0 E8              597             mov     a,R0
00D1 C3              598             clr     c
00D2 9E              599             subb    a,R6    ;temp-=(dx+1)
00D3 F8              600             mov     R0,a
00D4 500B            601             jnc     DrawLineQ4YS1
                     602             ;temp < 0
00D6 2D              603             add     a,R5    ;temp+=(dy+1)
00D7 F8              604             mov     R0,a
                     605             ;now x++
00D8 E5F0            606             mov     a,b     ;load bit mask
00DA 23              607             rl      a       ;rotate bit (x++)
00DB F5F0            608             mov     b,a     ;store it back
00DD 30F001          609             jnb     b.0,DrawLineQ4YS1
00E0 A3              610             inc     dptr    ;mask out of range, dptr++ (move to next byte, mask reseted back to
                              00000001b)
00E1                 611     DrawLineQ4YS1:  ;now we have to make y-- step
00E1 E582            612             mov     a,dpl
00E3 24E2            613             add     a,#low(-30)
00E5 F582            614             mov     dpl,a
00E7 E583            615             mov     a,dph
00E9 34FF            616             addc    a,#high(-30)
00EB F583            617             mov     dph,a   ;dptr-=xres
00ED DFDD            618             djnz    R7,DrawLineQ4YL1        ;next pixel?
                     619             ;done - hell yeah
00EF 8029            620             sjmp    DrawLineDone
                     621             ;======= dx > dy =======
00F1 EE              622     DrawLineQ4X:    mov     a,R6
00F2 F8              623             mov     R0,a    ;initial temp=dx
00F3 04              624             inc     a
00F4 FE              625             mov     R6,a    ;(dx+1) used for loop counter
00F5 FD              626             mov     R5,a    ;(dx+1)
00F6 0F              627             inc     R7      ;(dy+1)
                     628             ;
00F7 E0              629     DrawLineQ4XL1:  movx    a,@dptr
00F8 45F0            630             orl     a,b     ;add pixel into image
00FA F0              631             movx    @dptr,a
00FB E8              632             mov     a,R0
00FC C3              633             clr     c
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE    11

00FD 9F              634             subb    a,R7    ;temp-=(dy+1)
00FE F8              635             mov     R0,a
00FF 500E            636             jnc     DrawLineQ4XS1
                     637             ;temp < 0
0101 2D              638             add     a,R5    ;temp+=(dx+1)
0102 F8              639             mov     R0,a
                     640             ;now y--
0103 E582            641             mov     a,dpl
0105 24E2            642             add     a,#low(-30)
0107 F582            643             mov     dpl,a
0109 E583            644             mov     a,dph
010B 34FF            645             addc    a,#high(-30)
010D F583            646             mov     dph,a   ;dptr+=xres
010F                 647     DrawLineQ4XS1:  ;now we have to make x++ step
010F E5F0            648             mov     a,b     ;load bit mask
0111 23              649             rl      a       ;rotate bit (x++)
0112 F5F0            650             mov     b,a     ;store it back
0114 30F001          651             jnb     b.0,DrawLineQ4XS2
0117 A3              652             inc     dptr    ;mask out of range, dptr++ (move to next byte, mask reseted back to
                              00000001b)
0118 DEDD            653     DrawLineQ4XS2:  djnz    R6,DrawLineQ4XL1        ;next pixel?
                     654             ;done - hell yeah
                     655             ;ajmp   DrawLineDone
                     656             
011A 22              657     DrawLineDone:   ret     
                     658     
                     659     
                     660     ;==========================================================================================
                             ============ 
                     661     ;       draw icon
                     662     ;==========================================================================================
                             ============ 
                     663     ?PR?_DrawIcon?txt_graph SEGMENT CODE
                     664     ?DT?_DrawIcon?txt_graph SEGMENT DATA
                     665             PUBLIC  _DrawIcon
                     666             PUBLIC  ?_DrawIcon?BYTE
                     667     
----                 668             RSEG    ?DT?_DrawIcon?txt_graph
0000                 669     ?_DrawIcon?BYTE:        ds      6
                     670     
----                 671             RSEG    ?PR?_DrawIcon?txt_graph
                     672     
0000 ED              673     _DrawIcon:      mov     a,R5
0001 20E776          674             jb      acc.7,_DrawIconE        ;exit if y out of screen
0004 2500     F      675             add     a,?_DrawIcon?BYTE+3
0006 14              676             dec     a
0007 20E770          677             jb      acc.7,_DrawIconE        ;exit if (y+yres) out of screen
000A EF              678             mov     a,R7
000B C3              679             clr     c
000C 94F0            680             subb    a,#240
000E 506A            681             jnc     _DrawIconE
0010 EF              682             mov     a,R7
0011 2B              683             add     a,R3
0012 C3              684             clr     c
0013 94F1            685             subb    a,#241
0015 5063            686             jnc     _DrawIconE
                     687     
0017 741E            688             mov     a,#30
0019 8DF0            689             mov     b,R5
001B A4              690             mul     ab
001C F8              691             mov     R0,a
001D EF              692             mov     a,R7
001E 03              693             rr      a
001F 03              694             rr      a
0020 03              695             rr      a
0021 28              696             add     a,R0
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE    12

0022 F582            697             mov     dpl,a
0024 E4              698             clr     a
0025 35F0            699             addc    a,b
0027 F583            700             mov     dph,a
0029 7400     F      701             mov     a,#low(img0)
002B 2582            702             add     a,dpl
002D F582            703             mov     dpl,a
002F 7400     F      704             mov     a,#high(img0)
0031 3583            705             addc    a,dph
0033 F583            706             mov     dph,a   ;image pointer
0035 AF00     F      707             mov     R7,?_DrawIcon?BYTE+3    ;icon lines
0037 EB              708             mov     a,R3
0038 75F008          709             mov     b,#8
003B 84              710             div     ab
003C C5F0            711             xch     a,b
003E 6002            712             jz      _DrawIconS2
0040 05F0            713             inc     b
0042                 714     _DrawIconS2:
0042 AEF0            715     _DrawIconL2:    mov     R6,b
0044 A882            716     _DrawIconL1:    mov     R0,dpl
0046 A983            717             mov     R1,dph      
0048 850082   F      718             mov     dpl,?_DrawIcon?BYTE+5
004B 850083   F      719             mov     dph,?_DrawIcon?BYTE+4
004E E4              720             clr     a
004F 93              721             movc    a,@a+dptr
0050 A3              722             inc     dptr
0051 858200   F      723             mov     ?_DrawIcon?BYTE+5,dpl
0054 858300   F      724             mov     ?_DrawIcon?BYTE+4,dph
0057 8983            725             mov     dph,R1
0059 8882            726             mov     dpl,R0
005B F0              727             movx    @dptr,a
005C A3              728             inc     dptr
005D DEE5            729             djnz    R6,_DrawIconL1
005F C3              730     _DrawIconS1:    clr     c
0060 E582            731             mov     a,dpl
0062 95F0            732             subb    a,b
0064 F582            733             mov     dpl,a
0066 E583            734             mov     a,dph
0068 9400            735             subb    a,#0
006A F583            736             mov     dph,a
006C 741E            737             mov     a,#30
006E 2582            738             add     a,dpl
0070 F582            739             mov     dpl,a
0072 E583            740             mov     a,dph
0074 3400            741             addc    a,#0
0076 F583            742             mov     dph,a
0078 DFC8            743             djnz    R7,_DrawIconL2
007A 22              744     _DrawIconE:     ret
                     745     
                     746             END
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE    13

SYMBOL TABLE LISTING
------ ----- -------


N A M E                     T Y P E  V A L U E   ATTRIBUTES

?DT?_DRAWICON?TXT_GRAPH. .  D SEG    0006H       REL=UNIT
?DT?_DRAWLINE?TXT_GRAPH. .  D SEG    0004H       REL=UNIT
?PR?_DRAWICON?TXT_GRAPH. .  C SEG    007BH       REL=UNIT
?PR?_DRAWLINE?TXT_GRAPH. .  C SEG    011BH       REL=UNIT
?PR?_DRAWSTRBCK?TXT_GRAPH.  C SEG    00DCH       REL=UNIT
?PR?_DRAWSTRXRAM?TXT_GRAPH  C SEG    00FCH       REL=UNIT
?_DRAWICON?BYTE. . . . . .  D ADDR   0000H   R   SEG=?DT?_DRAWICON?TXT_GRAPH
?_DRAWLINE?BYTE. . . . . .  D ADDR   0000H   R   SEG=?DT?_DRAWLINE?TXT_GRAPH
ACC. . . . . . . . . . . .  D ADDR   00E0H   A   
AR1. . . . . . . . . . . .  D ADDR   0001H   A   
AR7. . . . . . . . . . . .  D ADDR   0007H   A   
AUXR1. . . . . . . . . . .  D ADDR   00A2H   A   
B. . . . . . . . . . . . .  D ADDR   00F0H   A   
DPH. . . . . . . . . . . .  D ADDR   0083H   A   
DPL. . . . . . . . . . . .  D ADDR   0082H   A   
DRAWLINEDONE . . . . . . .  C ADDR   011AH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEO2M1 . . . . . . .  C ADDR   0054H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEO2M2 . . . . . . .  C ADDR   0058H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEO2M3 . . . . . . .  C ADDR   005CH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1X. . . . . . . .  C ADDR   0094H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1XL1. . . . . . .  C ADDR   009AH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1XS1. . . . . . .  C ADDR   00B2H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1XS2. . . . . . .  C ADDR   00BBH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1YL1. . . . . . .  C ADDR   006EH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ1YS1. . . . . . .  C ADDR   0083H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4 . . . . . . . .  C ADDR   00BFH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4X. . . . . . . .  C ADDR   00F1H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4XL1. . . . . . .  C ADDR   00F7H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4XS1. . . . . . .  C ADDR   010FH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4XS2. . . . . . .  C ADDR   0118H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4YL1. . . . . . .  C ADDR   00CCH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQ4YS1. . . . . . .  C ADDR   00E1H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWLINEQC . . . . . . . .  C ADDR   002DH   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
DRAWSTRBCK . . . . . . . .  C ADDR   0000H   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKD. . . . . . . .  C ADDR   0055H   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKDE . . . . . . .  C ADDR   00DBH   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKDFL. . . . . . .  C ADDR   00BDH   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKDL . . . . . . .  C ADDR   009FH   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKDS . . . . . . .  C ADDR   00D9H   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKLL . . . . . . .  C ADDR   0027H   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRBCKNFL. . . . . . .  C ADDR   00AFH   R   SEG=?PR?_DRAWSTRBCK?TXT_GRAPH
DRAWSTRXRAMNI. . . . . . .  C ADDR   0016H   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
FONTLIST . . . . . . . . .  C ADDR   -----       EXT
IMG0 . . . . . . . . . . .  X ADDR   -----       EXT
LCDWRTXT . . . . . . . . .  C ADDR   003CH   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTD. . . . . . . . .  C ADDR   00FBH   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTDC . . . . . . . .  C ADDR   00F7H   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTDN . . . . . . . .  C ADDR   0043H   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTL1 . . . . . . . .  C ADDR   00D1H   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTL1S1 . . . . . . .  C ADDR   00ECH   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTNL . . . . . . . .  C ADDR   00ABH   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
LCDWRTXTNNL. . . . . . . .  C ADDR   00CFH   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH
STRTMP . . . . . . . . . .  X ADDR   -----       EXT
TXT_GRAPH. . . . . . . . .  N NUMB   -----       
XPOS . . . . . . . . . . .  D ADDR   -----       EXT
YPOS . . . . . . . . . . .  D ADDR   -----       EXT
_DRAWICON. . . . . . . . .  C ADDR   0000H   R   SEG=?PR?_DRAWICON?TXT_GRAPH
_DRAWICONE . . . . . . . .  C ADDR   007AH   R   SEG=?PR?_DRAWICON?TXT_GRAPH
_DRAWICONL1. . . . . . . .  C ADDR   0044H   R   SEG=?PR?_DRAWICON?TXT_GRAPH
_DRAWICONL2. . . . . . . .  C ADDR   0042H   R   SEG=?PR?_DRAWICON?TXT_GRAPH
A51 MACRO ASSEMBLER  TEXT_GRAPHICS_ROUTINES                                               05/08/2008 15:28:36 PAGE    14

_DRAWICONS1. . . . . . . .  C ADDR   005FH   R   SEG=?PR?_DRAWICON?TXT_GRAPH
_DRAWICONS2. . . . . . . .  C ADDR   0042H   R   SEG=?PR?_DRAWICON?TXT_GRAPH
_DRAWLINE. . . . . . . . .  C ADDR   0000H   R   SEG=?PR?_DRAWLINE?TXT_GRAPH
_DRAWSTRXRAM . . . . . . .  C ADDR   0000H   R   SEG=?PR?_DRAWSTRXRAM?TXT_GRAPH


REGISTER BANK(S) USED: 0 


ASSEMBLY COMPLETE.  0 WARNING(S), 0 ERROR(S)
