.module Lcd ;------------------------------------------------------------------------------- ;@doc:constant ; ; === Lcd.InstPort === ; ; Defines the address of the LCD's instruction (command) port. ; ;@doc:end ;------------------------------------------------------------------------------- InstPort = $10 ;------------------------------------------------------------------------------- ;@doc:constant ; ; === Lcd.DataPort === ; ; Defines the address of the LCD's data port. ; ;@doc:end ;------------------------------------------------------------------------------- DataPort = $11 ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.WriteInstruction === ; ; Writes a byte to the instruction port safely. ; ; INPUTS: ; REGISTERS ; * A - Value to write to the instruction port. ; ;@doc:end ;------------------------------------------------------------------------------- WriteInstruction out (InstPort),a jr Busy ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.WriteData === ; ; Writes a byte to the data port safely. ; ; INPUTS: ; REGISTERS ; * A - Value to write to the data port. ; ;@doc:end ;------------------------------------------------------------------------------- WriteData out (DataPort),a ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.Busy === ; ; Waits for the LCD to exit the busy state. ; ;@doc:end ;------------------------------------------------------------------------------- Busy in a,(InstPort) or a jp m,Busy ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.Copy === ; ; Copies the graphics buffer to the LCD. Note that this enables interrupts. ; ;@doc:end ;------------------------------------------------------------------------------- Copy push hl push de push bc push af .fcall "Speed.SlowDown" di - in a,(InstPort) or a jp m,- ld a,$80 out (InstPort),a ld hl,(Lcd.Buffer) ld de,-12-(-(12*64)+1) add hl,de ld a,$20 ld c,a inc hl dec hl --- ld b,64 inc c ld de,-(12*64)+1 push af - in a,(InstPort) or a jp m,- pop af out (InstPort),a add hl,de ld de,10 -- add hl,de inc hl inc hl inc de - in a,(InstPort) or a jp m,- ld a,(hl) out (DataPort),a dec de djnz -- ld a,c cp $2B+1 jr nz,--- .fcall "Speed.SpeedUp" pop af pop bc pop de pop hl ei ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.ClearBuffer === ; ; Clears the graphics buffer. ; ;@doc:end ;------------------------------------------------------------------------------- ClearBuffer push hl push de push bc ld hl,(Lcd.Buffer) ld d,h \ ld e,l inc de ld bc,767 ld (hl),0 ldir pop bc pop de pop hl ret .endmodule