A86: horiz/vert line routine


[Prev][Next][Index][Thread]

A86: horiz/vert line routine




could somebody please critique this code and help me optimize the horiz/vert
line
code? also, could you recomend how i might put the line drawing info into a
variable to make it less cluttered. if you want to run this code and see
what im looking for, just
compile it in asm studio 3.0. it works and wont crash.

thanx in advance
John A. Kemp, Jr.
<mitos@concentric.net>

#include "asm86.h"
#include "ti86asm.inc"


.org _asm_exec_ram

;------------------------------------------------------------

Start:

   call _clrLCD              ;clear the screen!
call  _runindicoff   ;turn indicator off
   ld bc,$0110                ;$01=#lines down, $10=#bytes across
   ld hl,$FC00               ;this is the first spot we want to write to
   call Horizline          ;draw horizontal line at FC00

ld b,1
ld hl,$FFB0
call Horizline

ld b,1
ld hl,$FF30
call Horizline

   ld a,%10000000
ld b,64
ld hl,$FC00
   call Vertline

ld a,%00000001
ld b,64
ld hl,$FC0F
call Vertline

;------------------------------------------------------------

ld hl,$0000      ;clear hl
   ld bc,$3402      ;location of cursor: b=34 c=02
   ld (_penCol),bc    ;put cursor location into mem
   ld hl,String     ;load text into hl
   call _vputs               ;this is a variable-width put string

;------------------------------------------------------------

loop:
call GET_KEY
cp K_EXIT
ret z
jr loop




;------------------------------------------------------------
; Horizontal Line
; hl - address in video mem
; c - width
; b - Counter, height
;------------------------------------------------------------

Horizline:
    ld a,%11111111           ;load --------- into a
    push bc                  ;save the counter of lines
    ld b,c                   ;make a new counter of bytes in the line (16)
HL_loop:
    ld (hl),a                ;put the bitmap in
    inc hl                   ;increment to the next byte on screen
    djnz HL_loop             ;and jump back until line is finished
    pop bc                   ;get the old counter back
    djnz Horizline           ;and keep going until all seven lines done
    ret
;------------------------------------------------------------
;------------------------------------------------------------


;------------------------------------------------------------
; Vertical Line
; hl - address in video mem
;  b - Counter for Height
; de - destroys
;------------------------------------------------------------

Vertline:
push bc                  ;save the counter of lines
   ld b,1                   ;make a new counter of bytes in the line (1)
VL_loop:
ld de,$0010
push de
ld d,a
or (hl)
ld (hl),a                ;put the bitmap in
ld a,d
pop de
   add hl,de                   ;increment to the next byte on screen
   djnz VL_loop          ;and jump back until line is finished
   pop bc                   ;get the old counter back
   djnz Vertline            ;and keep going until all seven lines done
ret
;------------------------------------------------------------
;------------------------------------------------------------

String:
.db "x^2+6=0",0

.end