X, Y koordianata az első 2 byte
Utána 6 vagy 8as csoportban az adatok amik a képernyőre Íródnak, egymás után...
Azaz a feléptés
XYDDDDDDDDDDDDDDDDDDDDDDD...
A képernyő X*Y méretű, és a DDDDD a simam memóriafeltöltési blokkot jelenti...
A ShowPic függvény:
Kód: Egész kijelölése
[_ShowPicture]
$EXTERNAL _DIV8, _MUL8 , _GetByteFromROM_EPROM
; RLE encoded. When the data after the byte is AA, it means it is a repeating
; sequence and the byte after it hold the number of repeats
; AB, AC , AF,AA, EE means show AB,AC and AF EE times
; needs more code but needs less picture data!
; show a picture with ShowPic x,y , label
; y+2 holds X, y+1 holds Y , y+0 holds EPROM/ROM flag, Z points to picture data
; The calling code uses for example
; clr r20
; clr r21
; st -y,r20 this way it will be referred to with y+4
; st -y,r21 and y+3
; ldi zl,low(plaatje * 2) to point to picture data
; ldi zh,high(plaatje * 2)
_ShowPicture:
CLR R1 ; repeats
CLR R2 ; char to repeat
clr r3 ; temp register
ld r23,y+ ; 255 means get from EEPROM, 0 means get from flash
call _GetByteFromROM ; get height of picture in pixels
St -y,r0 ; y+2
call _GetByteFromROM ; get width of picture in pixels
mov r16,r0
* ldi r20,_GLCD_MODE ; 8 bits in byte
call _Div8
st -y,r16 ; number of cols into y+1
st -y,r16 ; number of cols into y+0
ldd r16,y+4 ; get X pos
* ldi r20,_GLCD_MODE
call _Div8 ; correct
std y+4,r16 ; save column
_ShowPicture1:
ldd r16,y+3 ; get Y
* ldi r20,_GLCD_COLS ; 30 cols
call _Mul8 ; b MSb a LSB
ldd r24,y+4
Add r20,r24 ; add X
Clr r24
Adc R21,r24
subi r20,-0 ; add graph base address
sbci r21,-3
Rcall _set_address ; Point To Right Position
_ShowPicture2:
; Clr r24
; rcall _Gwrite_data
; *** New RLE encoding routine ***
cp r1,r3 ; is repeats 0 ?
brne _ShowPicture8 ; no
call _GetByteFromROM ; get next char
mov r2,r0 ; save char
mov r24,r0
cpi r24,&HAA ; test for repeat char must always be shown
breq _ShowPicture9 ; we need to show AA
call _GetByteFromROM ; is it RLE?
mov r24,r0
cpi r24,&HAA ; is it a RLE encoded char?
breq _ShowPicture10 ; yes
sbiw R30,1 ; no readjust pointer to graphic data
#IF _ROMSIZE>65536
brcc _ShowPicture2c ; when not skipping the boundery
* In r24, RAMPZ
Dec R24
* Out RAMPZ, R24
_ShowPicture2c:
#ENDIF
rjmp _ShowPicture11 ; show it
_ShowPicture9:
adiw r30,1
#IF _ROMSIZE>65536
brcc _ShowPicture9c ; when not skipping the boundery
* In r24, RAMPZ
Inc R24
* Out RAMPZ, R24
_ShowPicture9c:
#ENDIF
rjmp _ShowPicture11
_ShowPicture8:
;we are repeating
dec r1 ; adjust repeat counter
breq _showpicture2
rjmp _ShowPicture11 ; show it
_ShowPicture10:
call _GetByteFromROM ; get number of repeats
Mov r24,r0 ;
Tst r24 ; is it zero
Brne _showpicture15 ; no it isa RLE sequence
Sbiw r30,2 ; it is char AA we needto show
#IF _ROMSIZE>65536
brcc _ShowPicture10c ; when not skipping the boundery
* In r24, RAMPZ
Dec R24
* Out RAMPZ, R24
_ShowPicture10c:
#ENDIF
Rjmp _showpicture11 ; skip some code
_showpicture15:
mov r1,r0 ; save number of repeats
_ShowPicture11:
Clr r24
rcall _Gwrite_data
mov r24,r2
; *** end of RLE code ***
rcall _Gwrite_Data
ldi r24,&HC0
rcall _Gwrite_Cmd ; advance pointer
ldd r24,y+1 ; get column counter
dec r24
std y+1,r24 ; save col counter
brne _ShowPicture2 ; for all columns
ldd r24,y+0 ; get num of cols
std y+1,r24 ; save for the new row
ldd r24,y+2 ; get row counter
dec r24
std y+2,r24
brne _ShowPicture3 ; for all rows
adiw r28,5 ; adjust soft stack
Ret
_ShowPicture3:
ldd r24,y+3 ; get row counter
inc r24 ; advance
std y+3,r24
rjmp _ShowPicture1
[END]
3 külső függvényed van: getbyteEPROM, DIV8 és MUL8