ホームに戻る
 指定した座標に点を打つ

;--------------------------;
;   define                 ;
;--------------------------;
.186

;SW or WSC control
MAXPATHLEN    equ  64
SRAM_SEG      equ  1000h
HARDWARE      equ  0A0h

;BIOS control
INT_BIOS_VECTOR_BASE  equ  010h
INT_EXIT              equ  INT_BIOS_VECTOR_BASE + 0  ;program end
INT_KEY               equ  INT_BIOS_VECTOR_BASE + 1  ;key control
INT_DISP              equ  INT_BIOS_VECTOR_BASE + 2  ;screen control
INT_TEXT              equ  INT_BIOS_VECTOR_BASE + 3  ;text control

;IRAM setting
IRAM_Stack      equ  0E00h
IRAM_Font       equ  2000h
IRAM_Screen1    equ  1000h
IRAM_Screen2    equ  1800h
IRAM_Sprite     equ  0E00h
IRAM_Screen1_s  equ  2      ;2 * 2048 bytes
IRAM_Screen2_s  equ  3      ;3 * 2048 bytes
IRAM_Sprite_s   equ  7      ;7 * 512 bytes

;SCREEN control
SCREEN1          equ  0    ;Scrren 1
SCREEN2          equ  1    ;Screen 2
DCM_SCR1         equ  1    ;Display Screen 1 Enable
DCM_SCR2         equ  2    ;Display Screen 2 Enable
DCM_SPR          equ  4    ;Display Sprite Enable
SCREEN_SET_VRAM  equ  21h  ;Screen VRAM Addressの設定
SPRITE_SET_VRAM  equ  22h  ;Sprite VRAM Addressの設定

;LCD control
LCD_Display_Control  equ  000h  ; Display Control
LCD_Sprite_Start     equ  005h  ; Sprite Start Number
LCD_Sprite_Range     equ  006h  ; Sprite Range
LCD_Screen2_WinStart equ  008h  ; Screen2 Window Start Locate
LCD_Screen2_WinEnd   equ  00Ah  ; Screen2 Window End Locate
LCD_Sprite_WinStart  equ  00Ch  ; Sprite Window Start Locate
LCD_Sprite_WinEnd    equ  00Eh  ; Sprite Window End Locate
LCD_Screen1_Scroll   equ  010h  ; Screen1 Scroll Locate
LCD_Screen2_Scroll   equ  012h  ; Screen2 Scroll Locate
LCD_GRAY_0123        equ  01Ch  ; Gray 0123
LCD_GRAY_4567        equ  01Eh  ; Gray 4567
LCD_PALETTE00        equ  020h  ; Palette 0

;KEY control
KEY_WAIT             equ  002h


;--------------------------;
;   segment declarations   ;
;--------------------------;
TEXT         CSEG       ; code
_TEXT        CSEG       ; code
_GHOST_DATA  CSEG PARA  ; data in ROM, copied to RAM in startup

DATA         DSEG PARA  ; data in RAM
_DATA        DSEG PARA  ; data in RAM
BSS          DSEG       ; bss in RAM
_BSS         DSEG 'BSS' ; bss in RAM
HEAP         DSEG 'BSS' ; end of bss
ENDHEAP      DSEG 'BSS' ; end of heap

CGROUP       GROUP TEXT,_TEXT
DGROUP       GROUP DATA,_DATA,BSS,_BSS,HEAP,ENDHEAP


;--------------------------;
;   TEXT                   ;
;--------------------------;
TEXT         CSEG
ROMTOP::


;--------------------------;
;   _load0                 ;
;--------------------------;
_load0::
  PUSH  DS
  PUSH  DI
  PUSH  SI
  PUSH  CX
  PUSH  BX

;set SRAM_SEG to ES
  MOV   AX, SRAM_SEG
  MOV   ES, AX

;copy _GHOST_DATA to RAMTOP
  MOV   AX, CS
  SUB   AX, TEXT
  ADD   AX, _GHOST_DATA
  MOV   DS, AX
  XOR   SI, SI
  MOV   DI, RAMTOP
  MOV   CX, INITSIZE
  SHR   CX, 1
  CLD
  REP   MOVSW

  PUSH  ES
  POP   DS

;fill BSS with zero
  MOV   DI, BEGINBSS
  MOV   CX, ENDBSS
  SUB   CX, DI
  SHR   CX, 1
  XOR   AX, AX
  REP   STOSW

;set heap start position
  MOV   [__heap].W, BEGINHEAP

;set argv starting position at heap start
  MOV   [__argv].W, BEGINHEAP

  MOV   DX, CS
  MOV   AX, _run0

  POP   BX
  POP   CX
  POP   SI
  POP   DI
  POP   DS
  RETF


;--------------------------;
;   _run0                  ;
;--------------------------;
_run0::
  MOV   BP, SP

;set stack pointer
  MOV   AX, IRAM_Stack
  MOV   SP, AX

;set SRAM segment = DS = ES
  MOV   AX, SRAM_SEG
  MOV   DS, AX
  MOV   ES, AX

;initialize LCD
  XOR   AX, AX
  OUT   LCD_Display_Control, AX  ; display_control(0);
  OUT   LCD_Sprite_Start, AL     ; sprite_set_range(0,0);
  OUT   LCD_Sprite_Range, AL     ;
  OUT   LCD_Screen1_Scroll, AX   ; screen_set_scroll(SCREEN1, 0, 0);
  OUT   LCD_Screen2_Scroll, AX   ; screen_set_scrol2(SCREEN2, 0, 0);
  OUT   LCD_Screen2_WinStart, AX ;
  OUT   LCD_Sprite_WinStart, AX  ;
  MOV   AX, 0FFFFh
  OUT   LCD_Screen2_WinEnd, AX   ; screen2_set_window(0, 0, 255, 255);
  OUT   LCD_Sprite_WinEnd, AX    ; sprite_set_window(0, 0, 255, 255);

;check WS or WSC
  IN    AL, HARDWARE
  AND   AL, 02h
  JNZ   _run0_color

_run0_mono::
_run0_color::
;set SCREEN1 VRAM
  MOV  BX, IRAM_Screen1_s
  MOV  AL, SCREEN1
  MOV  AH, SCREEN_SET_VRAM
  INT  INT_DISP
;set SCREEN2 VRAM
  MOV  BX, IRAM_Screen2_s
  MOV  AL, SCREEN2
  MOV  AH, SCREEN_SET_VRAM
  INT  INT_DISP
;set SPRITE VRAM
  MOV  BX, IRAM_Sprite_s
  MOV  AH, SPRITE_SET_VRAM
  INT  INT_DISP
;set dsplay enable (Scrren 1 & Screen 2 & Sprite = Enable)
  MOV  AX, DCM_SCR1 + DCM_SCR2 + DCM_SPR
  OUT  LCD_Display_Control, AX

  MOV   CX, [BP + 8]  ; for argv
  MOV   BX, [BP + 6]  ; for argc
  PUSH  CX
  PUSH  BX
  CALL  _main


;--------------------------;
;   _main                  ;
;--------------------------;
_main::
  PUSH  BP
  MOV   BP,SP
  PUSH  DI
  PUSH  SI
  PUSH  CX
  PUSH  BX

;set color and palette
  MOV   AX, 07530h
  OUT   LCD_GRAY_0123, AX
  MOV   AX, 0FDB9h
  OUT   LCD_GRAY_4567, AX
  MOV   AX, 07420h
  OUT   LCD_PALETTE00, AX

;set font charactor
  XOR   AX, AX
  MOV   ES, AX
  MOV   DI, IRAM_Font + 0
  MOV   CX, 4096
  MOV   AX, 00000h
  CLD
  REP   STOSW

  PUSH  DS
  POP   ES

;fill SCREEN2 VRAM with 0-503 fonts
  SUB   SP, 6
  MOV   [BP-2].W, 0
  MOV   [BP-4].W, 0
  JMP   _1
_2:
  MOV   BX, [BP-2].W
  SHL   BX, 6
  ADD   BX, IRAM_Screen2
  MOV   [BP-6].W, 0
  JMP   _3
_4:
  MOV   AX, [BP-4].W
  MOV   SS:[BX].W, AX
  ADD   BX, 2
  INC   [BP-4].W
  INC   [BP-6].W
_3:
  CMP   [BP-6].W, 28
  JL    _4
  INC   [BP-2].W
_1:
  CMP   [BP-2].W, 18
  JL    _2
  ADD   SP, 6

;draw point on (x, y)   draw_point(x, y)
  SUB   SP, 4
  MOV   [BP-2].W, 100  ;x
  MOV   [BP-4].W, 50   ;y
  PUSH  [BP-4].W
  PUSH  [BP-2].W
  CALL  _draw_point
  ADD   SP, 8

;key wait
  MOV   AH, KEY_WAIT
  INT   INT_KEY

  XOR   AX, AX

  POP   BX
  POP   CX
  POP   SI
  POP   DI
  MOV   SP,BP
  POP   BP
  RET


;--------------------------;
;   _draw_point            ;
;--------------------------;
_draw_point::
  PUSH  BP
  MOV   BP, SP
  PUSH  CX
  PUSH  BX

;BP+4 = x BP+6 = y

  MOV   AX, [BP+4].W
  MOV   CX, AX
  AND   CX, 00007h
  SHR   AX, 3
  SHL   AX, 4
  MOV   [BP+4].W, AX
  MOV   AX, [BP+6].W
  SHR   AX, 3
  SHL   AX, 4
  MOV   BX, 28
  MUL   BX
  ADD   AX, [BP+4].W
  XOR   BX, BX
  MOV   BX, [BP+6].W
  AND   BX, 00007h
  SHL   BX, 1
  ADD   BX, AX
  ADD   BX, IRAM_Font

  MOV   AX, 08080h
  SHR   AX, CL
  MOV   CX, SS:[BX].W
  OR    CX, AX
  MOV   SS:[BX].W, CX

  POP   BX
  POP   CX
  MOV   SP,BP
  POP   BP
  RET


;--------------------------;
;   _exit0                 ;
;--------------------------;
_exit00::
__exit0::
__exit::
  INT   INT_EXIT


;--------------------------;
;   DATA                   ;
;--------------------------;
DATA         DSEG PARA
RAMTOP::

; FreyaOS process control block
__id::       DB 'LCC', 0
__pid::      DW 0
__ppid::     DW 0
__pcbid::    DW 0
__ppcbid::   DW 0
__ilib::     DW 0
             DW 0
__proc::     DW 0
             DW 0
__cwfs::     DW 0
             DW 0
__currentdir::
             RS MAXPATHLEN
__argv::     DW 0
__resource:: DW 0
             DW 0
__heap::     DW 0

_font_space::
             DW 00000h
             DW 00000h
             DW 00000h
             DW 00000h
             DW 00000h
             DW 00000h
             DW 00000h
             DW 00000h


;--------------------------;
;   BSS                    ;
;--------------------------;
BSS          DSEG
INITSIZE:
BEGINBSS:

HEAP         DSEG 'BSS'
ENDBSS:
BEGINHEAP:
ENDHEAP      DSEG 'BSS'

  end

inserted by FC2 system