;PAINTMOON.MAR - Program to paint a smiling moon to a VT100 or VT52 ; terminal. ; A demonstration of using macros to easily paint a ; picture on the screen in normal and special graphics ; modes. ; The screen should be pictured as a grid 80 columns ; wide and 24 rows long. ; ; ; Written by: Clair Garman ; Educational Services ; Digital Equipment Corporation ; Washington, DC ; .TITLE PAINT_MOON ; $DCDEF $LIBCLIDEF ; .MACRO P LINE,COL,NUM=1,BLINK MOVL #NUM,SOLID_DESC .IIF NB,, PUSHL #4 PUSHL #COL PUSHL #LINE PUSHAL SOLID_DESC CALLS NUM_ARGS,G^SCR$PUT_SCREEN .ENDM ; .MACRO PS LINE,COL,NUM=1 MOVL #NUM,SPACE_DESC PUSHL #COL PUSHL #LINE PUSHAL SPACE_DESC CALLS #3,G^SCR$PUT_SCREEN .ENDM ; .PSECT DATA PIC,NOEXE,LONG,NOSHR,WRT ; BIT_MASK: .LONG LIB$M_CLI_CTRLY IOSB: .BLKL 2 SYS_OUTPUT: .ASCID /SYS$OUTPUT/ CHAN: .WORD NUM_ARGS: .LONG 3 FLAG: .LONG DEVICE_TYPE: .LONG SOLID_DESC: .LONG .ADDRESS SOLID SOLID: .REPT 80 .ASCII /a/ .ENDR SPACE_DESC: .LONG .ADDRESS SPACE SPACE: .REPT 80 .ASCII / / .ENDR STAR_TEXT: .ASCII /*/ VT100_UP_DESC: .LONG 3 .ADDRESS VT100_UP VT100_DOWN_DESC:.LONG 3 .ADDRESS VT100_DOWN VT52_UP_DESC: .LONG 2 .ADDRESS VT52_UP VT52_DOWN_DESC: .LONG 2 .ADDRESS VT52_DOWN SAVE_DOWN_DESC: .LONG VT100_UP: .BYTE ^X1B ;Set special character set for VT100 .ASCII /(0/ ; ESC ( 0 VT100_DOWN: .BYTE ^X1B ;Set normal character set for VT100 .ASCII /(B/ ; ESC ( B VT52_UP: .BYTE ^X1B ;Set special character set for VT52 .ASCII /F/ ; ESC F VT52_DOWN: .BYTE ^X1B ;Set normal character set for VT52 .ASCII /G/ ; ESC G INVALID_TERM: .ASCID /*****ERROR - Invalid terminal type. *****/ ; .PSECT CODE PIC,EXE,LONG,SHR,NOWRT ; PAINT_MOON: .WORD ; ;Disable DCL CONTROL_Y PUSHAL BIT_MASK CALLS #1,G^LIB$DISABLE_CTRL ;Enable our own CONTROL_Y AST routine $ASSIGN_S DEVNAM=SYS_OUTPUT,CHAN=CHAN BLBS R0,.+10 PUSHL R0 CALLS #1,G^LIB$STOP $QIOW_S CHAN=CHAN,FUNC=#IO$_SETMODE!IO$M_CTRLYAST,- IOSB=IOSB,P1=CTRLY_AST BLBS R0,.+10 PUSHL R0 CALLS #1,G^LIB$STOP CMPW #1,L^IOSB BEQL .+15 MOVZWL L^IOSB,-(SP) CALLS #1,G^LIB$STOP ;Is the terminal a VT100 or a VT52? PUSHAL DEVICE_TYPE PUSHAL FLAG CALLS #2,G^LIB$SCREEN_INFO ; CMPZV #1,#1,FLAG,#1 ;Is the VT100 flag set BEQL VT100 ; CMPB #DT$_VT52,DEVICE_TYPE ;Is the terminal a VT52? BEQL VT52 ; PUSHAL INVALID_TERM CALLS #1,G^LIB$PUT_OUTPUT JMP END ;Terminal is VT100 compatible- switch to special character set VT100: MOVAL VT100_DOWN_DESC,SAVE_DOWN_DESC ;Save for later PUSHAL VT100_UP_DESC CALLS #1,G^LIB$PUT_OUTPUT BRW ERASE ;Terminal is a VT52 VT52: MOVAL VT52_DOWN_DESC,SAVE_DOWN_DESC ;Save for later PUSHAL VT52_UP_DESC CALLS #1,G^LIB$PUT_OUTPUT ;Erase the screen ERASE: PUSHL #1 PUSHL #1 CALLS #2,G^SCR$ERASE_PAGE ;Spiral from upper left P 1,11,8 P 2,10,8 P 3,9,8 P 4,8,8 P 5,7,7 P 6,6,7 P 7,5,6 P 8,4,6 P 9,3,6 P 10,2,6 P 11,2,6 P 12,2,6 PS 1,11,8 P 13,2,6 PS 2,10,8 P 14,3,6 PS 3,9,8 P 15,3,6 PS 4,8,8 P 16,4,6 PS 5,7,7 P 17,4,6 PS 6,6,7 P 18,5,6 PS 7,5,6 P 19,5,10 PS 8,4,6 P 20,6,10 PS 9,3,6 P 21,9,7 PS 10,2,6 P 22,12,4 PS 11,2,6 P 20,16,6 PS 12,2,6 P 21,16,6 PS 13,2,6 P 22,16,6 PS 14,3,6 P 21,22,5 PS 15,3,6 P 22,22,5 PS 16,4,6 P 23,22,5 PS 17,4,6 P 21,27,5 PS 18,5,6 P 22,27,5 PS 19,5,10 P 23,27,5 PS 20,6,10 P 21,32,5 PS 21,9,7 P 22,32,5 PS 22,12,4 P 23,32,5 PS 20,16,6 PS 21,16,6 PS 22,16,6 P 21,37,5 P 22,37,5 P 23,37,5 PS 21,22,5 PS 22,22,5 PS 23,22,5 P 21,42,5 P 22,42,5 P 23,42,5 PS 21,27,5 PS 22,27,5 PS 23,27,5 P 21,47,5 P 22,47,5 P 23,47,5 PS 21,32,5 PS 22,32,5 PS 23,32,5 P 23,52,5 P 22,52,5 P 21,52,5 PS 21,37,5 PS 22,37,5 PS 23,37,5 P 23,57,4 P 22,57,8 P 21,57,13 PS 21,42,5 PS 22,42,5 PS 23,42,5 P 20,60,12 P 19,65,10 PS 21,47,5 PS 22,47,5 PS 23,47,5 P 18,68,8 P 17,70,6 P 16,72,6 PS 21,52,5 PS 22,52,5 PS 23,52,5 P 15,73,5 P 14,75,5 P 13,76,4 PS 23,57,4 PS 22,57,8 PS 21,57,13 P 12,76,4 PS 20,60,12 P 11,76,4 PS 19,65,10 P 10,75,4 PS 18,68,8 P 9,74,4 PS 17,70,6 P 8,73,4 PS 16,72,6 P 7,72,4 PS 15,73,5 P 6,70,5 PS 14,75,5 P 5,65,6 PS 13,76,4 P 4,60,6 PS 12,76,4 P 3,55,6 PS 11,76,4 P 2,50,6 PS 10,75,4 P 2,44,6 PS 9,74,4 P 3,40,6 PS 8,73,4 P 3,35,5 PS 7,72,4 P 4,30,6 PS 6,70,5 P 5,28,5 PS 5,65,6 P 6,25,4 PS 4,60,6 P 7,23,4 PS 3,55,6 P 8,22,4 PS 2,50,6 P 9,21,4 PS 2,44,6 P 10,20,4 PS 3,40,6 P 11,19,4 PS 3,35,5 P 12,19,4 PS 2,50,6 P 13,19,4 PS 2,44,6 P 14,19,4 PS 3,40,6 P 15,20,4 PS 3,35,5 P 16,22,4 PS 4,30,6 P 17,24,5 PS 5,28,5 P 18,29,6 PS 6,25,4 P 19,34,6 PS 7,23,4 P 19,40,6 PS 8,22,4 P 18,45,5 PS 9,21,4 P 17,49,4 PS 10,20,4 P 16,52,3 PS 11,19,4 P 15,54,2 PS 12,19,4 P 14,55,1 PS 13,19,4 P 13,56,1 PS 14,19,4 P 12,57,1 PS 15,20,4 P 11,58,1 PS 16,22,4 P 10,59,1 PS 17,24,5 P 9,59,1 PS 18,29,6 PS 19,34,6 PS 19,40,6 PS 18,45,5 PS 17,49,4 PS 16,52,3 PS 15,54,2 PS 14,55,1 PS 13,56,1 PS 12,57,1 PS 11,58,1 PS 10,59,1 PS 9,59,1 ;Paint the crescent moon P 9,59,1 P 8,57,2 P 7,54,4 P 6,50,6 P 5,41,13 P 4,41,10 P 3,31,16 P 4,27,14 P 5,24,17 P 6,22,17 P 7,20,16 P 8,19,16 P 9,18,16 P 10,18,15 P 11,17,16 P 12,17,16 P 13,17,16 P 14,17,16 P 15,18,15 P 16,18,16 P 17,19,16 P 18,20,16 P 19,22,17 P 20,24,17 P 21,27,14 P 22,31,16 P 21,41,10 P 20,41,13 P 19,50,6 P 18,54,4 P 17,57,2 P 16,59,1 ;Stars in the sky MOVAL STAR_TEXT,SOLID_DESC+4 ;* to output MOVL #4,NUM_ARGS ;4 not 3 args to SCR$PUT_SCREEN P 12,67,,BLINK P 22,24,,BLINK P 2,7,,BLINK P 19,64,,BLINK P 11,12,,BLINK P 3,62,,BLINK P 20,8,,BLINK P 9,2,,BLINK P 2,68,,BLINK ;Grow the nose MOVAL SOLID,SOLID_DESC+4 ;Os to output MOVL #3,NUM_ARGS ;Back to 3 ars to SCR$PUT_SCREEN P 11,33,1 P 12,33,3 P 13,33,5 P 14,33,6 P 15,33,1 ;Generate the smile MOVAL SPACE,SOLID_DESC+4 ;Spaces to output P 14,32,1 P 17,29,6 P 16,26,8 P 15,25,2 P 14,23,1 P 14,25,1 P 13,24,4 P 12,28,1 P 11,26,4 P 10,25,1 P 10,28,1 P 9,26,6 P 8,32,1 ;Return to normal character set PUSHL SAVE_DOWN_DESC CALLS #1,G^LIB$PUT_OUTPUT ;Place cursor at the bottom of the screen PUSHL #1 PUSHL #23 CALLS #2,G^SCR$SET_CURSOR ; ; END: MOVL #SS$_NORMAL,R0 ;Status return ERR: RET ;Exit main routine ; ;CONTROL_Y AST routine ; CTRLY_AST: .WORD PUSHL SAVE_DOWN_DESC ;Return to normal character set CALLS #1,G^LIB$PUT_OUTPUT PUSHAL BIT_MASK CALLS #1,G^LIB$ENABLE_CTRL $EXIT_S ;Image exit .END PAINT_MOON