;;; -*- TI-Asm -*- ;;; ;;; Mimas - Assembly language IDE for the TI-83 Plus ;;; ;;; Copyright (C) 2010 Benjamin Moody ;;; ;;; This program is free software: you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as ;;; published by the Free Software Foundation; either version 3 of the ;;; License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . ;; DrawClearRectangle: ;; ;; Draw a dark rectangular border on the current screen buffer, and ;; clear the interior. ;; ;; Input: ;; - A = X coordinate of left edge of interior region ;; - E = Y coordinate of top edge of interior region ;; - B = width of interior region (> 0) ;; - C = height of interior region (> 0) ;; - (curScreenBuffer) = address of screen buffer ;; ;; Destroys: ;; - F, BC, HL P1_DrawClearRectangle: dec a dec e push bc inc b inc b inc c inc c call P1_FillRectangle pop bc inc a inc e ;; fall through ;; ClearRectangle: ;; ;; Clear a rectangular area of the current screen buffer. ;; ;; Input: ;; - A = X coordinate of left edge ;; - E = Y coordinate of top edge ;; - B = width (> 0) ;; - C = height (> 0) ;; - (curScreenBuffer) = address of screen buffer ;; ;; Destroys: ;; - F, BC, HL P1_ClearRectangle: or a jr P1_FillRectangle_Begin ;; FillRectangle: ;; ;; Fill a rectangular area of the current screen buffer. ;; ;; Input: ;; - A = X coordinate of left edge ;; - E = Y coordinate of top edge ;; - B = width (> 0) ;; - C = height (> 0) ;; - (curScreenBuffer) = address of screen buffer ;; ;; Destroys: ;; - F, BC, HL P1_FillRectangle: scf P1_FillRectangle_Begin: push de push af push af call P1_GetPixel ld e,c cpl ld c,a pop af sbc a,a ld d,a P1_FillRectangle_Loop: ;; HL = buffer address ;; B = width ;; E = height ;; C = inverted pixel mask ;; D = fill pattern push bc push hl scf P1_FillRectangle_QuickLoopDone: ld a,(hl) P1_FillRectangle_RowLoop: jr nc,P1_FillRectangle_NextByte xor d and c xor d rrc c djnz P1_FillRectangle_RowLoop ld (hl),a P1_FillRectangle_RowDone: pop hl ld c,12 add hl,bc pop bc dec e jr nz,P1_FillRectangle_Loop pop af pop de ret P1_FillRectangle_NextByte: ld (hl),a ld a,b P1_FillRectangle_QuickLoop: inc hl sub 8 jr c,P1_FillRectangle_QuickLoopDone ld (hl),d ld b,a jr z,P1_FillRectangle_RowDone jr P1_FillRectangle_QuickLoop P1_pixelBitTable: db 80h,40h,20h,10h,08h,04h,02h,01h NO_BYTE_CARRY P1_pixelBitTable ;; GetPixel: ;; ;; Get address of a pixel in the current screen buffer. ;; ;; Input: ;; - A = X coordinate ;; - E = Y coordinate ;; - (curScreenBuffer) = address of screen buffer ;; ;; Output: ;; - HL = address of pixel ;; - A = mask ;; ;; Destroys: ;; - F, DE P1_GetPixel: ld d,0 ld l,e ld h,d add hl,hl add hl,de add hl,hl add hl,hl ld e,a srl e srl e srl e add hl,de ld de,(curScreenBuffer) add hl,de P1_GetPixelBitMask: and 7 add a,low(P1_pixelBitTable) ld e,a ld d,high(P1_pixelBitTable) ld a,(de) ret