Skip to content

Commit

Permalink
Merge pull request #80 from venomix666/master
Browse files Browse the repository at this point in the history
Screen driver test application
  • Loading branch information
davidgiven authored Dec 16, 2023
2 parents d3e718d + 4086f65 commit 9ddd493
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ SCREEN_APPS = \
apps/cls.asm \
$(OBJDIR)/qe.com \
$(OBJDIR)/life.com \
$(OBJDIR)/apps/scrntest.com \

LIBCPM_OBJS = \
$(OBJDIR)/lib/printi.o \
Expand Down
14 changes: 12 additions & 2 deletions apps/drivers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ TTY_CONST = 0
TTY_CONIN = 1
TTY_CONOUT = 2

SCREEN_CLEAR = 2

SCREEN_GETSIZE = 1
SCREEN_CLEAR = 2
SCREEN_SETCURSOR = 3
SCREEN_GETCURSOR = 4
SCREEN_PUTCHAR = 5
SCREEN_PUTSTRING = 6
SCREEN_GETCHAR = 7
SCREEN_SHOWCURSOR = 8
SCREEN_SCROLLUP = 9
SCREEN_SCROLLDOWN = 10
SCREEN_CLEARTOEOL = 11
SCREEN_SETSTYLE = 12
\ vim: filetype=asm sw=4 ts=4 et


269 changes: 269 additions & 0 deletions apps/scrntest.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
\ Screen driver tester for CP/M-65 - Copyright (C) 2023 Henrik Lofgren
\ This file is licensed under the terms of the 2-clause BSD license. Please
\ see the COPYING file in the root project directory for the full text.

.include "cpm65.inc"
.include "drivers.inc"

.expand 1

.zp cur_x, 1
.zp cur_y, 1
.zp max_x, 1
.zp max_y, 1
.zp cur_vis, 1
.zp style, 1
.label string_init
.label string_a
.label BIOS
.label SCREEN
.label update_cursor

.zproc start

\ Find screen driver

ldy #BDOS_GET_BIOS
jsr BDOS
sta BIOS+1
stx BIOS+2

lda #<DRVID_SCREEN
ldx #>DRVID_SCREEN
ldy #BIOS_FINDDRV
jsr BIOS
\ Exit if no driver is found
.zif cs
rts
.zendif
sta SCREEN+1
stx SCREEN+2

\ Clear screen and print help
ldy #SCREEN_CLEAR
jsr SCREEN

lda #<string_init
ldx #>string_init
ldy #SCREEN_PUTSTRING
jsr SCREEN

\ Get screen size and initalize variables

ldy #SCREEN_GETSIZE
jsr SCREEN
sta max_x
stx max_y
lda #1
sta cur_vis

lda #0
sta style

mainloop:
\ Get and store current cursor position
ldy #SCREEN_GETCURSOR
jsr SCREEN
sta cur_x
stx cur_y

\ Get and parse command
lda #10
ldx #00
ldy #SCREEN_GETCHAR
jsr SCREEN
\ Convert to uppercase
cmp #0x61
bcc case_done
cmp #0x7a
bcs case_done
sec
sbc #0x20

case_done:
\ Cursor left
cmp #'A'
.zif eq
lda #0
cmp cur_x
.zif ne
dec cur_x
.zendif
jsr update_cursor
jmp mainloop
.zendif
\ Cursor right
cmp #'D'
.zif eq
lda max_x
cmp cur_x
.zif ne
inc cur_x
.zendif
jsr update_cursor
jmp mainloop
.zendif
\ Cursor up
cmp #'W'
.zif eq
lda #0
cmp cur_y
.zif ne
dec cur_y
.zendif
jsr update_cursor
jmp mainloop
.zendif
\ Cursor down
cmp #'S'
.zif eq
lda max_y
cmp cur_y
.zif ne
inc cur_y
.zendif
jsr update_cursor
jmp mainloop
.zendif

\ Put string
cmp #'P'
.zif eq
lda #<string_a
ldx #>string_a
ldy #SCREEN_PUTSTRING
jsr SCREEN
jmp mainloop
.zendif

\ Put character
cmp #'C'
.zif eq
lda #'C'
ldy #SCREEN_PUTCHAR
jsr SCREEN
.zendif

\ Toggle cursor
cmp #'V'
.zif eq
lda #0
cmp cur_vis
.zif ne
sta cur_vis
ldy #SCREEN_SHOWCURSOR
jsr SCREEN
jmp mainloop
.zendif
lda #1
sta cur_vis
ldy #SCREEN_SHOWCURSOR
jsr SCREEN
jmp mainloop
.zendif

\ Scroll up
cmp #'U'
.zif eq
ldy #SCREEN_SCROLLUP
jsr SCREEN
jmp mainloop
.zendif

\ Scroll down
cmp #'J'
.zif eq
ldy #SCREEN_SCROLLDOWN
jsr SCREEN
jmp mainloop
.zendif

\ Clear to end of line
cmp #'L'
.zif eq
ldy #SCREEN_CLEARTOEOL
jsr SCREEN
jmp mainloop
.zendif

\ Toggle style
cmp #'I'
.zif eq
lda #0
cmp style
.zif ne
sta style
ldy #SCREEN_SETSTYLE
jsr SCREEN
jmp mainloop
.zendif
lda #1
sta style
ldy #SCREEN_SETSTYLE
jsr SCREEN
jmp mainloop
.zendif
\ Clear screen and print help
cmp #'H'
.zif eq
ldy #SCREEN_CLEAR
jsr SCREEN
lda #<string_init
ldx #>string_init
ldy #SCREEN_PUTSTRING
jsr SCREEN
jmp mainloop
.zendif

\ Clear screen and quit
cmp #'Q'
.zif eq
ldy #SCREEN_CLEAR
jsr SCREEN
rts
.zendif
jmp mainloop
.zendproc

BIOS:
jmp 0

SCREEN:
jmp 0


.zproc update_cursor
lda cur_x
ldx cur_y
ldy #SCREEN_SETCURSOR
jsr SCREEN

rts
.zendproc

string_init:
.byte "CP/M-65 Screen driver tester\r\n\n"
.byte "W,A,S,D - Move cursor\r\n"
.byte "C - Put character\r\n"
.byte "P - Put string\r\n"
.byte "V - Toggle cursor visibility\r\n"
.byte "U - Scroll up\r\n"
.byte "J - Scroll down\r\n"
.byte "L - Clear to End of Line\r\n"
.byte "I - Toggle style\r\n"
.byte "H - Clear screen and print this help\r\n"
.byte "Q - Quit\r\n"
.byte 0

string_a:
.byte "String"
.byte 0

0 comments on commit 9ddd493

Please sign in to comment.