;****************************************************** ; ProcChr - decode host command and update display ; ; Original design by Daryl Rictor (c)2003-2004 ; ; Major redesign by Grant Searle 2007-13 ; - Commands modified ; - 40 char or 80 char support ; - Multi fonts and sizes ; - Medium resolution graphics ; - Line attributes to define text/graphics and font ;****************************************************** processChar: rcall setYfromRowCol ; restore chr under cursor mov temp,inpt mov inpt,charUnderCursor rcall putCharAtY mov inpt,temp mov J,cmdVal ; Was previous byte 1st char of a multi-byte command? cpi J, 0x00 brne processCommandPart2 mov J, inpt ; If delete char then jump cpi J,0x7F brne notDelete rjmp delete notDelete: ; If control code then handle it cpi J,0x20 brlo controlCode ; Otherwise print the character rjmp printableASCII controlCode: ldi ZH, 0x08 ; no, setup jump table page address mov ZL, inpt ; put the input chr into Z ijmp ; jump table based on INPT ;--------------------------------------------------------------------------------------------------------------------------- processCommandPart2: cmd1: mov J,cmdVal cpi J, 0x0E ; set column brne cmd2 cpi inpt, 0x50 ; check column = 0-79 brlo setColumn rjmp cmdComplete setColumn: mov column, inpt ; update hpos rcall putCursorOnScreen ; put cursor back on screen if >39 on a 40 char line rcall setYfromRowCol ld charUnderCursor, Y ; save chr under cursor rjmp cmdComplete cmd2: cpi J, 0x0F ; set row brne cmd3 cpi inpt, 0x19 ; check row = 0-24 brlo setRow rjmp cmdComplete setRow: mov row, inpt ; save new vertical position rcall getCurrentLineAtt ; set the current attribute to match the cursor line rcall setLineAtt ; to ensure double-height lines are reset to top line at cursor rcall setYfromRowCol ld charUnderCursor, Y ; save chr under cursor rjmp cmdComplete cmd3: cpi J, 0x1A ; Force Char Into RAM brne cmd4 rcall printableASCII rjmp cmdComplete cmd4: cpi J, 0x18 ; Set font attribute brne cmd5 mov activeLineAtt, inpt ; Set the attribute to use for all subsequent lines rcall setLineAtt ; Set the attribute on the current line to match rcall putCursorOnScreen ; put cursor back on screen if >39 on a 40 char line rjmp cmdComplete cmd5: cpi J, 0x02 ; Set cursor character brne cmd6 mov cursorChar, inpt rjmp cmdComplete cmd6: cpi J, 0x05 ; Set pixel brne cmd7 mov J,previousInpt cpi J, 0xFF ; If previous input was FF then this is first param brne setPixel ; otherwise this is second param so method can be called mov previousInpt, inpt ; Store current input as the previous input value ret ; Just return, don't terminate command cmd7: cpi J, 0x06 ; Reset pixel brne cmdComplete mov J,previousInpt cpi J, 0xFF brne resetPixel mov previousInpt, inpt ret ; Just return, don't terminate command cmdComplete: ldi J,0x00 mov cmdVal, J ret ;--------------------------------------------------------------------------------------------------------------------------- resetPixel: ldi J,0x00 mov temp,J rjmp setOrResetPixel setPixel: ldi J,0x01 mov temp,J setOrResetPixel: ; Validate coordinates and exit if out of range mov J,inpt ; Y=0..99 cpi J,100 brsh cmdComplete mov J,previousInpt ; X=0..159 cpi J,160 brsh cmdComplete ; inpt contains the Y coordinate, previousInpt contains X coordinate push row push column ; Get the row of location that needs to be manipulated mov J,inpt lsr J lsr J andi J,0x1F mov row,J ; Get attribute location into Z ldi ZH, 0x08 ldi ZL, 0xD0 add ZL, row ; Get line attribute into J ld J,Z ; If already set then skip sbrc J,ATT_GRAPHICS rjmp graphicsLineSet ; If not already graphics then set the attribute and clear the line ldi column,0x00 ; Get the location for start of line rcall setYfromRowCol ldi J, 0x00 clrGraphics: st Y+, J inc column cpi column, 0x50 brne clrGraphics ; clear to end of line ; Force graphics property for the row ldi J,0x00 ori J, 1<