; -------- Text(Mode 0) Functions For GABasic --------
; Gabriel Fernandez 2000

; ---- CLS
Cls:
  CMP word [screenmode], 0
  JNE Screen13cls
  mov edi, 0B8000h
  mov ecx, 2000
  xor al, al
  mov ah, [screencolor]
  rep stosw
  mov word [textx], 0
  mov word [texty], 0
  RET
Screen13cls:
  mov edi, 0A0000h
  mov ecx, 64000
  mov al, [screencolor]
  rep stosb
  RET
RET     ; END CLS

; ---- PRINT
; EAX = String Offset

Print:
  xor edi, edi
  mov ecx, [eax]
  Cmp ecx, 0
  Je skipprint
  mov di, [texty]
  mov bx, [texty]
  shl di, 4
  shl bx, 6
  mov dx, [textx]
  add di, bx
  shl di, 1
  shl dx, 1
  add di, dx
  add edi, 0B8000h
  add eax, 4
  mov bh, [screencolor]
PrintNextChar:
  dec ecx
  mov bl, [eax]
  mov [edi], bl
  mov [edi+1], bh
  add edi, 2
  inc eax
CMP ecx, 0
jne PrintNextChar

  inc word [texty]
  mov word [textx], 0
skipprint:
RET  ; END Print
