.module Modes .include "Modes/Small.asm" .include "Modes/Large.asm" ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Modes.Set === ; ; Sets a screen mode. This sets the text viewport and character dimensions, ; homes the cursor, clears the viewport and sets the scaling modes. ; ;@doc:end ;------------------------------------------------------------------------------- Set ld (Vdu.Mode),a push hl push de and $7F jr z,Set.Small cp 3 jr z,Set.Small Set.Large ld a,8 ld (Vdu.Text.CharWidth),a ld (Vdu.Text.CharHeight),a ld (Vdu.Text.Graphical.CharWidth),a ld (Vdu.Text.Graphical.CharHeight),a ld hl,Large.Clear.Routine \ ld (Text.Clear+1),hl ld hl,Large.GetBufferCharAddress.Routine \ ld (Text.GetBufferCharAddress+1),hl ld hl,Large.PutMapNoWriteBuffer.Routine \ ld (Text.4.PutMapNoWriteBuffer),hl ld hl,Large.PutMap.Routine \ ld (Text.4.PutMap),hl ld hl,Large.GetBufferPixelAddress.Routine \ ld (Text.GetBufferPixelAddress+1),hl ld hl,Large.Scroll.Up.Routine \ ld (Text.Scroll.Up+1),hl ld hl,Large.Scroll.Down.Routine \ ld (Text.Scroll.Down+1),hl ld de,11*256+7 jr Set.Exit Set.Small ld a,4 ld (Vdu.Text.CharWidth),a ld (Vdu.Text.Graphical.CharWidth),a ld a,6 ld (Vdu.Text.CharHeight),a ld (Vdu.Text.Graphical.CharHeight),a ld hl,Small.Clear.Routine \ ld (Text.Clear+1),hl ld hl,Small.GetBufferCharAddress.Routine \ ld (Text.GetBufferCharAddress+1),hl ld hl,Small.PutMapNoWriteBuffer.Routine \ ld (Text.4.PutMapNoWriteBuffer),hl ld hl,Small.PutMap.Routine \ ld (Text.4.PutMap),hl ld hl,Small.GetBufferPixelAddress.Routine \ ld (Text.GetBufferPixelAddress+1),hl ld hl,Small.Scroll.Up.Routine \ ld (Text.Scroll.Up+1),hl ld hl,Small.Scroll.Down.Routine \ ld (Text.Scroll.Down+1),hl ld de,23*256+9 Set.Exit ld hl,(Text.4.PutMapNoWriteBuffer) ld (Text.PutMapNoWritebuffer+1),hl ld hl,(Text.4.PutMap) ld (Text.PutMap+1),hl xor a ld (Vdu.Text.Cursor.X),a ld (Vdu.Text.Cursor.Y),a ld (Vdu.Text.Bounds.MinX),a ld (Vdu.Text.Bounds.MinY),a ld a,d ld (Vdu.Text.Bounds.MaxX),a ld (Vdu.Text.Bounds.Abs.MaxX),a ld a,e ld (Vdu.Text.Bounds.MaxY),a ld (Vdu.Text.Bounds.Abs.MaxY),a call Vdu.Text.Clear ; Set graphics scale factor. ld a,4 .fcall "Graphics.SetScaleFactor.X" ld a,(Vdu.Mode) or a ld a,4 jr nz,+ inc a + .fcall "Graphics.SetScaleFactor.Y" ; Set Y axis direction. ld a,$C3 ; JP nn + ld (Graphics.FlipY16),a ld (Graphics.FlipY8),a ; Re-enable the cursor. ld a,(Text.StateFlags) set Text.State.CursorEnabled,a ld (Text.StateFlags),a pop de pop hl ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Lcd.CopyConditional === ; ; Repaints the screen if required. ; ;@doc:end ;------------------------------------------------------------------------------- Lcd.CopyConditional ld a,(WriteToLcdEnabled) or a ret z .fcall "Lcd.Copy" ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Clear.Exit === ; ; Repaints the screen if required, then moves the cursor home. ; ;@doc:end ;------------------------------------------------------------------------------- Clear.Exit push hl push de push bc push af xor a ld (Vdu.CommandQueue.Length),a ld (Page.LinesOutput),a ld a,(Bounds.MinX) ld (Cursor.X),a ld a,(Bounds.MinY) ld (Cursor.Y),a call Lcd.CopyConditional pop af pop bc pop de pop hl pop ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Scroll.Up.Exit === ; ; Repaints the screen if required, then moves the copy cursor up a line if ; required. Jump here after mode-specific Scroll.Up code. ; ;@doc:end ;------------------------------------------------------------------------------- Scroll.Up.Exit push hl push de push bc push af ld a,(WriteToLcdEnabled) or a jr z,+ .fcall "Lcd.Copy" + ld a,(CopyKey.Enabled) or a jr z,+ ld a,(Bounds.MinY) ld b,a ld a,(CopyKey.Cursor.Y) cp b jr z,+ dec a ld (CopyKey.Cursor.Y),a + pop af pop bc pop de pop hl ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Viewport.TextIsFullScreen === ; ; Checks whether the text viewport fills the entire screen or not. ; ; OUTPUTS: ; REGISTERS: ; * F - Z if the text viewport fills the entire screen, NZ otherwise. ; ; DESTROYED: ; REGISTERS: ; * A. ; ;@doc:end ;------------------------------------------------------------------------------- Viewport.TextIsFullScreen ld a,(Bounds.MinX) or a ret nz ld a,(Bounds.MinY) or a ret nz push bc ld bc,(Vdu.Text.Bounds.Abs) ld a,(Bounds.MaxX) cp c jr nz,+ ld a,(Bounds.MaxY) cp b + pop bc ret ;------------------------------------------------------------------------------- ;@doc:routine ; ; === Viewport.TextIsFullWidth === ; ; Checks whether the text viewport fills the width of the screen or not. ; ; OUTPUTS: ; REGISTERS: ; * F - Z if the text viewport fills the width of the screen, NZ otherwise. ; ; DESTROYED: ; REGISTERS: ; * A. ; ;@doc:end ;------------------------------------------------------------------------------- Viewport.TextIsFullWidth ld a,(Bounds.MinX) or a ret nz push bc ld a,(Vdu.Text.Bounds.Abs.MaxX) ld b,a ld a,(Bounds.MaxX) cp b pop bc ret .endmodule