I was trying to port some of my Grammer routines last night and I made a code that might draw a B/W 96x64 screen using the same kind of 768-byte buffer we are used to. From my calculations, it can handle about 20FPS at 6MHz. Since I don't know really how to use the LCD ports, I was basically just guessing. I also assumed that the colors were defined as %1111111111111111 = black and %0000000000000000 = white.
Code:
GramBWImage:
;Inputs:
; HL points to the data
; the rectangle is already defined
;Outputs:
; B,D,E are all 0
; A is either $00 or $FF
; C is the last byte of the buffer
ld de,3 ;10 10
BWLoop: ;
ld b,8 ;7 7*768
ld c,(hl) ;7 7*768
BWLoop2: ;
rlc c ;8 8*6144
sbc a,a ;4 4*6144
out (LCDDataPort),a ;11 11*6144
out (LCDDataPort),a ;11 11*6144
djnz BWLoop ;13|8 768(13*8-5)
dec d ;4 4*768
jr nz,BWLoop ;12|7 12*768-15
dec e ;4 4*3
jr nz,BWLoop ;12|7 12*3-5
ret ;10 10
;Total time:
;308016 t-states.
And then I have no clue how grayscale is defined, so I think I probably made a routine to display a colorful (not grayscale) image. However, at least it is a start!
Code:
GramGrayImage:
;Inputs:
; HL points to one buffer
; IX points to another buffer
; the rectangle is already defined
;Outputs:
; B,D,E are all 0
; A is either $00 or $FF
; C is the last byte of the buffer
ld de,3
GrayLoop:
ld b,8
ld c,(ix)
GrayLoop2:
rlc c
sbc a,a
out (LCDDataPort),a
rlc (hl)
sbc a,a
out (LCDDataPort),a
djnz GrayLoop
dec d
jr nz,GrayLoop
dec e
jr nz,GrayLoop
ret
Aside from that, since we have 128KB of RAM, for backwards compatibility I was thinking of using one of the RAM pages to hold two 768-byte buffers (or 1536-byte buffers for grayscale). The first buffer would hold the current data, the second would hold the data from the last screen update. This way, when you update the screen, you can look for changed bytes and only update what needs to be updated.
I also came up with this routine for drawing an 8x8 sprite (full color):
(define the window size first in both cases)
Code:
ld bc,128*256+LCDDataPort
ld hl,spriteLoc
outir
And for a 16x16 sprite:
Code:
ld bc,LCDDataPort
ld hl,spriteLoc
outir
outir