; -------- GABasic Code ---------
; Code Include file
; Please don't edit this file

[BITS 32]
[section .text]
GLOBAL _WdosxStart
_WdosxStart:

MOV AX, DS
MOV ES, AX

; Process the command line and exe path
mov ebx, exepath
mov edx, 0

DEC ESI
Mov eax, [edi]
add edi, 4
CNextChar1:
  inc edx
  mov cl, [eax]
  mov [ebx], cl
  inc ebx
  inc eax
  cmp cl, 0
JNE CNextChar1

DEC edx
mov [exepathlen], edx

mov ebx, commandline
mov edx, 0

CMP ESI, 0
JE Skipcommand
NextCommand:
  DEC ESI
  Mov eax, [edi]
  add edi, 4
CNextChar2:
    inc edx
    mov cl, [eax]
    mov [ebx], cl
    inc ebx
    inc eax
    cmp cl, 0
    JNE CNextChar2
  CMP esi, 0
JNE NextCommand

DEC EDX
Skipcommand:
mov [commandlen], edx

mov ah, 9
mov edx, WDosX
int 21h

; ---- Create Temporally string block

MOV Eax, [TmpStringSize]
ADD EAX, 32000
Call NEAR AllocBlock
Mov [StringOffset], eax
mov ebx, StringHandle
mov [ebx], si
mov [ebx+2], di

; ---- Allocate block on rmode mem

MOV eax, 100h
MOV EBX, 1250
INT 31h
JNC Clabel1
  MOV ax, 2
  call EndProgram
Clabel1:
MOV [rmodeblock], ax
MOV [rmodesel], dx

mov ah, 1
mov ch, 20h
int 10h

mov ebx, 0
mov ah, 3
int 10h
mov [textx], dl
mov [texty], dh
