.module Small .include "Small.Scroll.asm" ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Vdu.Text.Clear === ; ; Clears the text viewport and cursor position. ; ;@doc:end ;------------------------------------------------------------------------------- Clear.Routine push hl push de push bc push af call Viewport.TextIsFullScreen jp z,Clear.FullScreen call Viewport.TextIsFullWidth jp z,Clear.FullWidth Clear.Subregion ld a,(Bounds.MinX) ld c,a ld a,(Bounds.MaxX) sub c inc a ld b,a - push bc call Clear.Column pop bc inc c djnz - jp Clear.Exit Clear.Column ; In: C = column to clear. ; Clear column on video buffer. ld a,(Bounds.MinY) call ATimes72 ld de,(Lcd.Buffer) add hl,de ld d,0 ld e,c srl e add hl,de ld a,(Bounds.MinY) ld e,a ld a,(Bounds.MaxY) sub e inc a add a,a ld b,a add a,a add a,b ld b,a ld de,12 push bc ld a,(Vdu.Text.BackgroundColour) bit 6,a jr z,Clear.Column.White Clear.Column.Black bit 0,c ld c,$F0 jr z,+ ld c,$0F + - ld a,(hl) or c ld (hl),a add hl,de djnz - jr Cleared.Column.Graphics Clear.Column.White bit 0,c ld c,$0F jr z,+ ld c,$F0 + - ld a,(hl) and c ld (hl),a add hl,de djnz - Cleared.Column.Graphics pop bc ; Clear column on text buffer. ld a,(Bounds.MinY) call ATimes24 ld de,Text.Buffer add hl,de ld b,0 add hl,bc ld a,(Bounds.MinY) ld e,a ld a,(Bounds.MaxY) sub e inc a ld b,a ld a,' ' ld de,24 - ld (hl),a add hl,de djnz - ret jp Clear.Exit Clear.FullWidth ; Clear video buffer. ld a,(Bounds.MinY) ld b,a ld a,(Bounds.MaxY) sub b inc a call ATimes72 push hl ld a,(Bounds.MinY) call ATimes72 ld de,(Lcd.Buffer) add hl,de ld d,h ld e,l inc de pop bc dec bc ld a,(Vdu.Text.BackgroundColour) add a,a add a,a sbc a,a ld (hl),a ldir ; Clear character buffer. ld a,(Bounds.MinY) ld b,a ld a,(Bounds.MaxY) sub b inc a call ATimes24 push hl ld a,(Bounds.MinY) call ATimes24 ld de,Text.Buffer add hl,de ld d,h ld e,l inc de pop bc dec bc ld (hl),' ' ldir jp Clear.Exit Clear.FullScreen ld a,(Vdu.Text.BackgroundColour) add a,a add a,a sbc a,a ld hl,(Lcd.Buffer) ld d,h \ ld e,l inc de ld bc,10*6*12-1 ld (hl),a ldir ld hl,Vdu.Text.Buffer ld de,Vdu.Text.Buffer+1 ld bc,24*10-1 ld (hl),' ' ldir Clear.Exit pop af pop bc pop de pop hl jp Modes.Clear.Exit ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Console.PutMapNoWriteBuffer === ; ; Puts a character on the display at the current cursor position, ; but does not write to the underlying character buffer. ; ; INPUTS: ; REGISTERS ; * A - The code of the character to put on the display. ; ;@doc:end ;------------------------------------------------------------------------------- PutMapNoWriteBuffer.Routine push hl jr PutMapMain ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Console.PutMap === ; ; Puts a character on the display and character buffer at the current cursor ; position. ; ; INPUTS: ; REGISTERS ; * A - The code of the character to put on the display and buffer. ; ;@doc:end ;------------------------------------------------------------------------------- PutMap.Routine push hl call GetBufferCharAddress ld (hl),a PutMapMain push de push bc push af push ix ; Find pointer to character data in font. ld h,0 ld l,a add hl,hl ld d,h ld e,l add hl,hl add hl,de ld de,Resources.Font add hl,de push hl pop ix ; Find pointer to character cell on graph buffer. ld a,(Cursor.Y) add a,a ld b,a add a,a add a,b add a,a add a,a ld h,0 ld l,a ld d,h ld e,l add hl,hl add hl,de ld a,(Cursor.X) srl a ld d,0 ld e,a add hl,de ld de,(Lcd.Buffer) add hl,de ; Set row. ld a,(Cursor.Y) add a,a ld b,a add a,a add a,b add a,$80 call Lcd.WriteInstruction ; Set column and character mask. ld a,(Cursor.X) ld c,%11110000 srl a jr nc,+ ld c,%00001111 + add a,$20 call Lcd.WriteInstruction ; Is WriteToLcdEnabled? ld a,(WriteToLcdEnabled) or a ld a,$C3 ; JP NN jr nz,+ ld a,$C9 ; RET + ld (PutMapWriteLcdIndirection),a ; Output the character. ld b,6 ld de,12 ; ix -> font data. ; hl -> graph buffer. ; de = 12 ; b = 6 ; c = column mask (where we need to write). ld a,(BackgroundColour) bit 6,a jr z,BlackOnWhiteMap WhiteOnBlackMap ld a,(ForegroundColour) bit 6,a jr z,+ ; Black on black. ld ix,Resources.Font+' '*6 + - ld a,(hl) ; Read existing value on buffer. or c ; Mask out old value. ld (hl),a ; Store back on buffer. ld a,(ix+0) ; Read value from font. and c ; Mask against column selection. xor (hl) ; Invert against buffer. ld (hl),a ; Write to buffer. inc ix add hl,de call PutMapWriteLcdIndirection djnz - pop ix pop af pop bc pop de pop hl ret BlackOnWhiteMap ld a,(ForegroundColour) bit 6,a jr nz,+ ; White on white. ld ix,Resources.Font+' '*6 + - ld a,(hl) ; Read existing value on buffer. cpl ; Invert it. or c ; Mask out. cpl ; Invert again; this has erased the place we're writing. ld (hl),a ; Store back on buffer. ld a,(ix+0) ; Read data from font. and c ; Mask desired character. or (hl) ; OR to buffer. ld (hl),a ; Write to buffer. inc ix add hl,de call PutMapWriteLcdIndirection djnz - ExitPutMap pop ix pop af pop bc pop de pop hl ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Console.GetBufferCharAddress === ; ; Gets the address of the character cell in the buffer under the cursor. ; ; OUPTUTS: ; REGISTERS ; * HL - Address of the character cell under the cursor. ; ;@doc:end ;------------------------------------------------------------------------------- GetBufferCharAddress.Routine push af push de ld a,(Cursor.Y) add a,a ; 2 add a,a ; 4 ld l,a add a,a ; 8 add a,l ; 12 add a,a ; 24 ld l,a ld a,(Cursor.X) add a,l ld h,0 ld l,a ld de,Buffer add hl,de pop de pop af ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Console.GetBufferPixelAddress === ; ; Gets the address of the pixel data under the cursor. ; ; OUPTUTS: ; REGISTERS ; * HL - Address of the pixel under the cursor. ; * B - Bitmask for character. ; HARDWARE ; * LCD driver - points at correct row and column. ; ;@doc:end ;------------------------------------------------------------------------------- GetBufferPixelAddress.Routine ld a,(Cursor.Y) ld h,0 ld d,h ; Row address = a * 72 ; 72 = 64 + 8 add a,a ; *2 add a,a ; *4 add a,a ; *8 ld e,a add a,a ; *16 ld l,a add hl,hl ; *32 add hl,hl ; *64 add hl,de ; *72 ld de,(Lcd.Buffer) add hl,de ; hl -> row ld a,(Cursor.X) ld b,$0F srl a ld c,a jr nc,+ ld b,$F0 + ld e,a ld d,0 add hl,de ; hl -> Lcd.Buffer ; b = Bitmask. ; Now, set LCD pointer. ld a,c ; From earlier. :) add a,$20 call Lcd.WriteInstruction ; Row ld a,(Cursor.Y) add a,a ld c,a add a,a add a,c add a,$80 call Lcd.WriteInstruction ret .endmodule