Difference between revisions of "Z80 Routines:Graphic:Fastcopy"
From WikiTI
m (→Remarks and Improvements: Make it more clear that graph buffer is erased. The code comments still made it sound like a general purpose routine.) |
Guillaumeh (Talk | contribs) m (→Remarks and Improvements) |
||
Line 47: | Line 47: | ||
* The di instruction is dispensable. | * The di instruction is dispensable. | ||
− | * Some instructions in Joe Wingbermuehle's Fastcopy are only there for having enough delay between two outputs to the LCD driver. One can modify Fastcopy to | + | * Some instructions in Joe Wingbermuehle's Fastcopy are only there for having enough delay between two outputs to the LCD driver. One can modify Fastcopy to change these useless instructions into instructions that will clear the Graph Buffer at the same time : |
<nowiki> | <nowiki> | ||
;-----> Copy the gbuf to the screen and clear graph buffer (fast) | ;-----> Copy the gbuf to the screen and clear graph buffer (fast) |
Revision as of 10:43, 25 April 2005
The Fastcopy routine is used to copy the content of the Graph Buffer to the screen. It concerns all TI-z80 calculators, except TI-85 and TI-86, that has a special RAM area directly mapped to the screen.
Fastcopy is widely used, because the rom call _GrBufCpy waits too long between each output to the LCD driver. Using Fastcopy instead of _GrBufCpy increases significantly the speed of a program if it refreshes often the display (such as a lot of games). Most shells have this routine as built-in (ION, MirageOS, Venus ...).
Here is Joe Wingbermuehle's version, which is the one used in ION.
;-----> Copy the gbuf to the screen (fast) ;Input: nothing ;Output:graph buffer is copied to the screen fastCopy: di ld a,$80 out ($10),a ld hl,gbuf-12-(-(12*64)+1) ld a,$20 ld c,a inc hl dec hl fastCopyAgain: ld b,64 inc c ld de,-(12*64)+1 out ($10),a add hl,de ld de,10 fastCopyLoop: add hl,de inc hl inc hl inc de ld a,(hl) out ($11),a dec de djnz fastCopyLoop ld a,c cp $2B+1 jr nz,fastCopyAgain ret
Remarks and Improvements
- The di instruction is dispensable.
- Some instructions in Joe Wingbermuehle's Fastcopy are only there for having enough delay between two outputs to the LCD driver. One can modify Fastcopy to change these useless instructions into instructions that will clear the Graph Buffer at the same time :
;-----> Copy the gbuf to the screen and clear graph buffer (fast) ;Input: nothing ;Output:graph buffer is copied to the screen and subsequently cleared fastCopy: di ld a,$80 out ($10),a ld hl,gbuf-12-(-(12*64)+1) ld a,$20 ld c,a inc hl dec hl fastCopyAgain: ld b,64 inc c ld de,-(12*64)+1 out ($10),a add hl,de ld de,11 fastCopyLoop: add hl,de inc hl inc de ld a,(hl) ld (hl),0 ; clears the graph buffer at the same time out ($11),a dec de djnz fastCopyLoop ld a,c cp $2B+1 jr nz,fastCopyAgain ret
ld (hl),0 takes 10 cycles, so we can do with one less inc hl (6 cycles) and thus load 11 into de instead of 10.