Compare commits

..

22 Commits

Author SHA1 Message Date
郭宇翔
9aa36a0f96 Merge pull request #26 from LJS08/patch-1
Fix: 翻译不完全04_day/asmhead.nas
2024-04-01 16:14:55 +08:00
LJS80
9bb71ea5ce Update asmhead.nas 2023-06-19 23:06:13 +08:00
郭宇翔
f8b2930281 Merge pull request #9 from sky5454/patch-2
Update README.md
2020-08-10 15:07:34 +08:00
郭宇翔
c462063e0b Update ipl10.nas
Fixed #10
2020-08-10 09:40:14 +08:00
郭宇翔
dade193e1f Update README.md 2020-08-10 09:36:42 +08:00
sky5454
670d454b4e Update README.md
Add HELP
2019-05-27 22:13:46 +08:00
郭宇翔
6ee187a190 Merge pull request #8 from sky5454/patch-1
Update helloos.nas
2019-05-26 23:29:22 +08:00
sky5454
7d59920a37 Update helloos.nas
修正:“必??”改为“必须是”,"字?"改为"字节"
不知道是不是仓库主人误操作,还是git的bug?
2019-05-26 21:48:38 +08:00
郭宇翔
b308a9e295 fix imgout BPB data error
fixed #3
2018-08-08 00:26:36 +08:00
Yourtion
a28136d3de bug fix 2016-05-31 18:13:22 +08:00
Yourtion
438eeb5135 Update README 2016-05-21 00:37:05 +08:00
Yourtion
d9d034cf43 update 2016-05-21 00:31:13 +08:00
Yourtion
c8be7ff36f update README 2016-05-21 00:30:29 +08:00
Yourtion
140774a293 bug fix 2016-05-21 00:24:41 +08:00
Yourtion
7c2fc66927 add screen 2016-05-20 15:28:31 +08:00
Yourtion
636c1a8c3d Update README 2016-05-20 15:16:20 +08:00
Yourtion
c177821913 整理 2016-05-20 14:56:29 +08:00
Yourtion
febac10ebf IPL的改良 2016-05-20 14:49:26 +08:00
Yourtion
0e31ff06ca bug fix 2016-05-20 14:27:07 +08:00
Yourtion
08d19d7512 图片阅览器 2016-05-20 14:05:13 +08:00
Yourtion
b2d31a8e54 MML播放器 2016-05-20 13:38:43 +08:00
Yourtion
72532c8cd7 文本阅览器 2016-05-20 12:03:41 +08:00
57 changed files with 2609 additions and 119 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
*.hrb
*.lst
*.map
*.bim
*.hrb

View File

@@ -12,15 +12,15 @@
DW 224 ; 根目录大小一般为224项
DW 2880 ; 该磁盘大小必须为2880扇区1440*1024/512
DB 0xf0 ; 磁盘类型必须为0xf0
DW 9 ; FAT的长度??9扇区
DW 9 ; FAT的长度须是9扇区
DW 18 ; 一个磁道track有几个扇区必须为18
DW 2 ; 磁头数(必??2
DW 2 ; 磁头数(必须是2
DD 0 ; 不使用分区必须是0
DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码
DB "HELLO-OS " ; 磁盘的名称必须为11字?,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
DB "HELLO-OS " ; 磁盘的名称必须为11字,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必须是8字,不足填空格)
RESB 18 ; 先空出18字节
; 程序主体
@@ -47,4 +47,4 @@
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 4600
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 1469432
RESB 1469432

View File

@@ -6,7 +6,7 @@
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
JMP entry
DB 0xeb, 0x4e, 0x90
DB 0x90
DB "HELLOIPL" ; 启动扇区名称8字节
DW 512 ; 每个扇区sector大小必须512字节
DB 1 ; 簇cluster大小必须为1个扇区

View File

@@ -53,7 +53,7 @@ retry:
MOV BX,0
MOV DL,0x00 ; A驱动器
INT 0x13 ; 调用磁盘BIOS
JNC next ; 没出错则跳转到fin
JNC next ; 没出错则跳转到next
ADD SI,1 ; 往SI加1
CMP SI,5 ; 比较SI与5
JAE error ; SI >= 5 跳转到error

View File

@@ -15,7 +15,7 @@ VRAM EQU 0x0ff8 ; 图像缓冲区的起始地址
ORG 0xc200 ; 这个的程序要被装载的内存地址
; 画面モードを設定
; 设置画面模式
MOV AL,0x13 ; VGA显卡320x200x8bit
MOV AH,0x00

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -14,7 +14,7 @@ default :
#文件生成规则
haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
haribote.img : haribote/ipl10.bin haribote/haribote.sys Makefile \
a/a.hrb hello3/hello3.hrb hello4/hello4.hrb hello5/hello5.hrb \
winhelo/winhelo.hrb winhelo2/winhelo2.hrb winhelo3/winhelo3.hrb \
star1/star1.hrb stars/stars.hrb stars2/stars2.hrb \
@@ -23,9 +23,9 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
sosu/sosu.hrb sosu2/sosu2.hrb sosu3/sosu3.hrb \
type/type.hrb iroha/iroha.hrb chklang/chklang.hrb \
notrec/notrec.hrb bball/bball.hrb invader/invader.hrb \
calc/calc.hrb
calc/calc.hrb tview/tview.hrb mmlplay/mmlplay.hrb gview/gview.hrb
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
wbinimg src:haribote/ipl20.bin len:512 from:0 to:0 \
wbinimg src:haribote/ipl10.bin len:512 from:0 to:0 \
copy from:haribote/haribote.sys to:@: \
copy from:haribote/jp.nas to:@: \
copy from:make.bat to:@: \
@@ -56,6 +56,15 @@ haribote.img : haribote/ipl20.bin haribote/haribote.sys Makefile \
copy from:bball/bball.hrb to:@: \
copy from:invader/invader.hrb to:@: \
copy from:calc/calc.hrb to:@: \
copy from:tview/tview.hrb to:@: \
copy from:mmlplay/mmlplay.hrb to:@: \
copy from:mmldata/kirakira.mml to:@: \
copy from:mmldata/fujisan.mml to:@: \
copy from:mmldata/daigo.mml to:@: \
copy from:mmldata/daiku.mml to:@: \
copy from:gview/gview.hrb to:@: \
copy from:pictdata/fujisan.jpg to:@: \
copy from:pictdata/night.bmp to:@: \
copy from:nihongo/nihongo.fnt to:@: \
imgout:haribote.img
@@ -100,6 +109,9 @@ full :
$(MAKE) -C bball
$(MAKE) -C invader
$(MAKE) -C calc
$(MAKE) -C tview
$(MAKE) -C mmlplay
$(MAKE) -C gview
$(MAKE) haribote.img
run_full :
@@ -152,6 +164,9 @@ clean_full :
$(MAKE) -C bball clean
$(MAKE) -C invader clean
$(MAKE) -C calc clean
$(MAKE) -C tview clean
$(MAKE) -C mmlplay clean
$(MAKE) -C gview clean
src_only_full :
$(MAKE) -C haribote src_only
@@ -183,6 +198,9 @@ src_only_full :
$(MAKE) -C bball src_only
$(MAKE) -C invader src_only
$(MAKE) -C calc src_only
$(MAKE) -C tview src_only
$(MAKE) -C mmlplay src_only
$(MAKE) -C gview src_only
-$(DEL) haribote.img
refresh :

View File

@@ -3,3 +3,6 @@ STACK = 1k
MALLOC = 0k
include ../app_make.txt
$(APP).hrb : $(APP).org Makefile
$(COPY) $(APP).org $(APP).hrb

Binary file not shown.

View File

@@ -35,10 +35,10 @@ $(STDAPP).bim : $(APP).obj $(STDLIBPATH)stdlib.lib Makefile ../app_make.txt
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
$(APP).obj $(STDLIBPATH)stdlib.lib
haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
haribote.img : ../haribote/ipl10.bin ../haribote/haribote.sys $(APP).hrb \
Makefile ../app_make.txt
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
wbinimg src:../haribote/ipl20.bin len:512 from:0 to:0 \
wbinimg src:../haribote/ipl10.bin len:512 from:0 to:0 \
copy from:../haribote/haribote.sys to:@: \
copy from:$(APP).hrb to:@: \
copy from:../nihongo/nihongo.fnt to:@: \

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

90
30_day/gview/Makefile Normal file
View File

@@ -0,0 +1,90 @@
APP = gview
STACK = 4480k
MALLOC = 0k
TOOLPATH = ../../z_tools/
INCPATH = ../../z_tools/haribote/
APILIBPATH = ../apilib/
HARIBOTEPATH = ../haribote/
MAKE = $(TOOLPATH)make.exe -r
NASK = $(TOOLPATH)nask.exe
CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) -I../ -Os -Wall -quiet
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
OBJ2BIM = $(TOOLPATH)obj2bim.exe
MAKEFONT = $(TOOLPATH)makefont.exe
BIN2OBJ = $(TOOLPATH)bin2obj.exe
BIM2HRB = $(TOOLPATH)bim2hrb.exe
BIM2BIN = $(TOOLPATH)bim2bin.exe
RULEFILE = ../haribote.rul
EDIMG = $(TOOLPATH)edimg.exe
IMGTOL = $(TOOLPATH)imgtol.com
GOLIB = $(TOOLPATH)golib00.exe
COPY = copy
DEL = del
#默认动作
default :
$(MAKE) $(APP).hrb
#文件生成规则
$(APP).bim : $(APP).obj bmp.obj jpeg.obj $(APILIBPATH)apilib.lib Makefile
$(OBJ2BIM) @$(RULEFILE) out:$(APP).bim map:$(APP).map stack:$(STACK) \
$(APP).obj jpeg.obj bmp.obj $(APILIBPATH)apilib.lib
haribote.img : ../haribote/ipl20.bin ../haribote/haribote.sys $(APP).hrb \
Makefile
$(EDIMG) imgin:../../z_tools/fdimg0at.tek \
wbinimg src:../haribote/ipl20.bin len:512 from:0 to:0 \
copy from:../haribote/haribote.sys to:@: \
copy from:$(APP).hrb to:@: \
copy from:../nihongo/nihongo.fnt to:@: \
imgout:haribote.img
# 其他指令
%.gas : %.c ../apilib.h Makefile
$(CC1) -o $*.gas $*.c
%.nas : %.gas Makefile
$(GAS2NASK) $*.gas $*.nas
%.obj : %.nas Makefile
$(NASK) $*.nas $*.obj $*.lst
%.org : %.bim Makefile
$(BIM2HRB) $*.bim $*.org $(MALLOC)
%.hrb : %.org Makefile
$(BIM2BIN) -osacmp in:$*.org out:$*.hrb
# 运行程序
run :
$(MAKE) haribote.img
$(COPY) haribote.img ..\..\z_tools\qemu\fdimage0.bin
$(MAKE) -C ../../z_tools/qemu
full :
$(MAKE) -C $(APILIBPATH)
$(MAKE) $(APP).hrb
run_full :
$(MAKE) -C $(APILIBPATH)
$(MAKE) -C ../haribote
$(MAKE) run
clean :
-$(DEL) *.lst
-$(DEL) gview.obj
-$(DEL) jpeg.obj
-$(DEL) *.map
-$(DEL) *.bim
-$(DEL) *.org
-$(DEL) haribote.img
src_only :
$(MAKE) clean
-$(DEL) $(APP).hrb

646
30_day/gview/bmp.nasm Normal file
View File

@@ -0,0 +1,646 @@
; BMP decode routine by I.Tak. 2003
section .text align=1
[bits 32]
;BMP File Structure (I can't understand MS.)
struc BMP
;FILE HEADER
.fType: resw 1 ;BM
.fSize: resd 1 ;whole file size
resd 1 ;reserved
.fOffBits: resd 1 ;offset from file top to image
;INFO HEADER
.iSize: resd 1 ;INFO HEADER size
.iWidth: resd 1 ;Image Width in pixels
.iHeight: resd 1 ;Image Height in pixels
.iPlanes: resw 1 ;must be 1
.iBitCount: resw 1 ;BitPerPixel 1, 4, 8, 24 (and 15,16 for new OS/2 ?)
.iCompression: resd 1 ;Compress Type. 0 for none, then SizeImage=0
.iSizeImage: resd 1 ;Image Size(compressed)
.iXPPM: resd 1 ;X Pixel Per Meter
.iYPPM: resd 1
.iClrUsed: resd 1 ;Number of used ColorQuad (0 for whole Quad)
.iClrImportant: resd 1 ;Number of Important ColorQuad.
endstruc
struc BMPOS2
;FILE HEADER
.fType: resw 1 ;BM
.fSize: resd 1 ;whole file size
resd 1 ;reserved
.fOffBits: resd 1 ;offset from file top to image
;CORE HEADER
.iSize: resd 1 ;CORE HEADER size
.iWidth: resw 1 ;Image Width in pixels
.iHeight: resw 1 ;Image Height in pixels
.iPlanes: resw 1 ;must be 1
.iBitCount: resw 1 ;BitPerPixel 1, 4, 8, 24 (and 15,16 for new OS/2 ?)
endstruc
; B/W bmp can also have palettes. The first for 0, second for 1.
struc CQuad
.b: resb 1
.g: resb 1
.r: resb 1
resb 1 ;reserved
endstruc
%if 0
int info_BMP(struct DLL_STRPICENV *env, int *info, int size, UCHAR *fp);
/* 1 (0?), 0 */
int decode0_BMP(struct DLL_STRPICENV *env, int size, UCHAR *fp,
int b_type, UCHAR *buf, int skip);
/* 0 */
envは64KBのワークエリアである8dwは返り値用になっている
, 使JPEG_initで
base_imgを作るのはdecodeのときだけでいいと思う
%endif
[absolute 0] ;naskなら[section .bss] org 0 かな win32だからダメか
bmpinfo:
.regs: resd 4
.reteip: resd 1
.env: resd 1
.info: resd 1
.size: resd 1
.module: resd 1
[absolute 0]
info:
.type: resd 1 ;1 for BMP, 2 for JPEG
resd 1 ;0
.width: resd 1
.height: resd 1
[section .text]
[global _info_BMP]
_info_BMP:
push ebx
push ebp
push esi
push edi
mov esi, [esp+bmpinfo.module]
mov eax, [esp+bmpinfo.size]
call bmpHeader
test edi, edi
jz .ret
mov esi, [esp+bmpinfo.info]
mov [esi+info.width], eax
mov [esi+info.height], ecx
mov [esi+info.type], edi ;=1
dec edi
mov [esi+info.type+4], edi ;=0
inc edi
.ret: mov eax, edi
pop edi
pop esi
pop ebp
pop ebx
ret
;in: esi=module, eax=size
;ret:eax=width, ecx=hegiht, edx=paletteSize, ebx=palette
; ebp=bpp, esi=endOfImage, edi=successFlag
bmpHeader:
lea edx, [esi+eax] ;moduleEnd
xor edi, edi
push edx
xor edx, edx
cmp eax, byte BMP.iSize+4
jbe ..@ret ;中継してしまう
cmp word[esi],'BM'
je .notMAC
sub esi, byte -128
add eax, byte -128
pop ebx
push eax
cmp eax, byte BMP.iSize+4
..@ret: jbe .ret
cmp word[esi], 'BM'
jne .ret
.notMAC:
;;MS,OS/2 フォーマット確認
mov ecx, [esi +BMP.iSize]
cmp ecx, byte 12 ;OS/2 format.
jne .MS
cmp eax, byte BMPOS2_size
jbe .ret ;coreヘッダなし
lea ebx, [esi+ecx+14] ;palette
movzx eax, word[esi+BMPOS2.iWidth] ;width
movzx ecx, word[esi+BMPOS2.iHeight] ;height
movzx ebp, word[esi+BMPOS2.iBitCount] ;bpp
mov dl, 3 ;paletteSize
jmp short .endif
.MS: cmp eax, byte BMP_size
jbe .ret ;infoヘッダなし
lea ebx, [esi+ecx+14]
sub ecx,byte 40
jne .ret ;unknownFormat
cmp ecx, [esi+BMP.iCompression]
jne .ret ;Compressed.
mov eax, [esi+BMP.iWidth] ;width
mov ecx, [esi+BMP.iHeight] ;height
movzx ebp, word[esi +BMP.iBitCount] ;bpp
mov dl, 4 ;paletteSize
.endif:
add esi, [esi +BMP.fOffBits]
;sizeが小さい場合heightを削ってで<E381A6>
;読めると答えるべきだろう。今はエラー
push edx
push eax
mul ebp ;eax=width*bpp
add eax, byte 7
shr eax, 3 ;lineSizeWithoutPudding
mov edx, eax
add eax, byte 3 ;size<1GBを仮定してedxを無<E38292>
and al, -4 ;lineSizeWithPudding
sub edx, eax ;-puddingSize
push edx
mul ecx
pop edx
add esi, eax
add esi, edx ;最終行の最後にはpuddingがないと見るべき
cmp esi, [esp+8] ;endOfModule
pop eax
ja .ret2
sub esi, edx ;esi=endOfImage
inc edi ;succeeded!
.ret2: pop edx
.ret: add esp, byte 4
ret
;***************************************************************
; 小ささ優先で作っているが, 速さ優先で作った昔のよりいいかも。
; 品質最低の高速モードのみ作ってい<E381A6>
[absolute 0]
decode:
.regs: resd 4
.reteip: resd 1
.env: resd 1
.size: resd 1
.module: resd 1
.outputType: resd 1
.dest: resd 1
.skip: resd 1
[section .text]
[global _decode0_BMP]
_decode0_BMP:
push ebx
push ebp
push esi
push edi
mov esi, [esp+decode.module]
mov eax, [esp+decode.size]
call bmpHeader
;ret:eax=width, ecx=hegiht, edx=paletteSize, ebx=palette
; ebp=bpp, esi=endOfImage, edi=successFlag
test edi,edi
jz .error
mov edi, [esp+decode.dest]
push dword[esp+decode.outputType]
push dword[esp+4+decode.skip]
push ecx ;height
push eax
push edx
mul ebp
add eax, byte 31
shr eax, 3
and al, -4
push eax
mov edx, ebp
mov ebp, esp
call bmp2beta ;ecx!=0 for error
add esp, byte bb.size
mov eax, ecx
test ecx, ecx
jz .ret
.error: push byte 1
pop eax
.ret: pop edi
pop esi
pop ebp
pop ebx
ret
[absolute -4*2]
bb:
.col0: resd 1 ;bpp1で使う
.reteip: resd 1
.sw: resd 1 ;byte
.paletteSize: resd 1 ;byte
.w: resd 1 ;pixel
.h: resd 1
.s: resd 1
.t: resd 1
.size: equ $-$$
[section .text]
;eax=?, ecx=height, edx=bpp, ebx=palette
;ebp=bb, esi=endOfImage, edi=dest
bmp2beta:
mov al, [ebp+bb.t]
and al, 0x7f
cmp al, 2
je near buf16
cmp al, 4
je buf32
mov ecx, esp ;!=0
ret
;===============================================================
; Buffer mode 4
;===============================================================
buf32:
dec edx
je near .bpp1
sub edx, byte 4-1
je .bpp4
sub edx, byte 8-4
je .bpp8
sub edx, byte 24-8
je .bpp24
mov ecx, esp ;!=0
ret
;---------------------------------------------------
; 24bpp BMP to 4byte bufer
;---------------------------------------------------
.bpp24:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;bb.w=width(pixel), bb.s=skipByte, bb.h=height
;bb.t=outputType, bb.sw=sourceWidthByte
.do24.1:
sub esi, [ebp+bb.sw] ;esi=startOfLine
push ecx
push esi
mov ecx, [ebp+bb.w]
.do24.2:
mov al, [esi]
mov [edi+3], dl
mov [edi], al
mov al, [esi+1]
mov [edi+1], al
mov al, [esi+2]
mov [edi+2], al
add esi, byte 3
add edi, byte 4
dec ecx
jnz .do24.2
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do24.1
ret
;---------------------------------------------------
; 8bpp BMP to 4byte buffer
;---------------------------------------------------
.bpp8:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov dl, 255
mov eax, [ebp+bb.paletteSize]
sub ebx, eax
shl eax, 8
add ebx, eax ;ebx += paletteSize*255
.do8.1:
mov eax, [ebx]
sub ebx, [ebp+bb.paletteSize]
and eax, 0x00ffffff
dec edx
push eax
jns .do8.1
.do8.2:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do8.3:
xor eax, eax
add edi, byte 4
mov al, [esi]
inc esi
;AGI stole
mov eax, [esp+eax*4+8]
dec ecx
mov [edi-4], eax
jnz .do8.3
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do8.2
add esp, 256*4 ;palette
ret
;---------------------------------------------------
; 4bpp BMP to 4byte buffer
;---------------------------------------------------
.bpp4:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov dl, 16
mov eax, [ebp+bb.paletteSize]
sub ebx, eax
shl eax, 4
add ebx, eax ;ebx+=eax*15
.do4.1
mov eax, [ebx]
sub ebx, [ebp+bb.paletteSize]
and eax, 0x00ffffff
dec edx
push eax
jnz .do4.1
.do4.2:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do4.3:
xor edx, edx
mov al, [esi]
mov dl, al
inc esi
shr dl, 4
and eax, byte 15
add edi, byte 4
dec ecx
mov edx, [esp+edx*4+8]
mov eax, [esp+eax*4+8]
mov [edi-4], edx
jz .wend
mov [edi], eax
add edi, byte 4
dec ecx
jnz .do4.3
.wend: pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do4.2
add esp, 16*4 ;palette
ret
;---------------------------------------------------
; 1bpp BMP to 4byte buffer
;---------------------------------------------------
.bpp1:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov eax, [ebx]
add ebx, [ebp+bb.paletteSize]
and eax, 0x00ffffff
mov ebx, [ebx]
and ebx, 0x00ffffff
xor ebx, eax
;push ebx
push eax
.do1.1:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do1.2:
mov dl, [esi]
inc esi
push esi
mov esi, 8
.do1.3:
add edi, byte 4
add dl, dl
sbb eax, eax
and eax, ebx
xor eax, [ebp+bb.col0]
dec ecx
mov [edi-4], eax
jz .wend1bpp
dec esi
jnz .do1.3
pop esi
jmp short .do1.2
.wend1bpp:pop ecx
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do1.1
pop eax
ret
;===============================================
; Buffer mode 2byte
;===============================================
buf16:
dec edx
je near .bpp1
sub edx, byte 4-1
je near .bpp4
sub edx, byte 8-4
je .bpp8
sub edx, byte 24-8
je .bpp24
mov ecx, esp
ret
;---------------------------------------------------
; 24bpp BMP to 2byte bufer
;---------------------------------------------------
.bpp24:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
.do24.1:
sub esi, [ebp+bb.sw] ;esi=startOfLine
push ecx
push esi
mov ecx, [ebp+bb.w]
.do24.2:
mov al, [esi+2]
shl eax, 16
mov ax, [esi]
add esi, byte 3
;減色処理 eax=24bitColor, edx=work, ecx=counter, ebx=work
;川合さんの趣味で没ったルーチンを持ってくるもよし(ぉ
;誤差拡散ルーチンを持ってくるもよし
shr ah, 2 ;???????? RRRRRrrr 00GGGGGG BBBBBbbb
inc edi
shr eax, 3 ;000????? ???RRRRR rrr00GGG GGGBBBBB
shl ax, 5 ;000????? ???RRRRR GGGGGGBB BBB00000
inc edi
shr eax, 5 ;00000000 ???????? RRRRRGGG GGGBBBBB
dec ecx
mov [edi-2], ax
jnz .do24.2
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do24.1
ret
;---------------------------------------------------
; 8bpp BMP to 2byte buffer
;---------------------------------------------------
.bpp8:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov dl, 255
mov eax, [ebp+bb.paletteSize]
sub ebx, eax
shl eax, 8
add ebx, eax ;ebx += paletteSize*255
.do8.1:
mov eax, [ebx]
sub ebx, [ebp+bb.paletteSize]
call .paletteConv
dec edx
push eax
jns .do8.1
.do8.2:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do8.3:
xor eax, eax
add edi, byte 2
mov al, [esi]
inc esi
;AGI stole
mov eax, [esp+eax*4+8]
dec ecx
mov [edi-2], ax
jnz .do8.3
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do8.2
add esp, 256*4 ;palette
ret
;---------------------------------------------------
; 4bpp BMP to 2byte buffer
;---------------------------------------------------
.bpp4:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov dl, 16
mov eax, [ebp+bb.paletteSize]
sub ebx, eax
shl eax, 4
add ebx, eax ;ebx+=eax*15
.do4.1:
mov eax, [ebx]
sub ebx, [ebp+bb.paletteSize]
call .paletteConv
dec edx
push eax
jnz .do4.1
.do4.2:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do4.3:
xor edx, edx
mov al, [esi]
mov dl, al
inc esi
shr dl, 4
and eax, byte 15
add edi, byte 2
dec ecx
mov edx, [esp+edx*4+8]
mov eax, [esp+eax*4+8]
mov [edi-2], dx
jz .wend
mov [edi], ax
add edi, byte 2
dec ecx
jnz .do4.3
.wend: pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do4.2
add esp, 16*4 ;palette
ret
;---------------------------------------------------
; 1bpp BMP to 2byte buffer
;---------------------------------------------------
.bpp1:
;ecx=height, edx=0, ebx=palette
;esi=endOfImage, edi=destinationBuffer
;pallete変換
mov eax, [ebx]
add ebx, [ebp+bb.paletteSize]
call .paletteConv
push eax
mov eax, [ebx]
call .paletteConv
pop ebx
xchg eax, ebx
xor ebx, eax
push eax
.do1.1:
sub esi, [ebp+bb.sw] ;esi=firstLineStart
push ecx
push esi
mov ecx, [ebp+bb.w]
.do1.2:
mov dl, [esi]
inc esi
push esi
mov esi, 8
.do1.3:
add dl, dl
inc edi
sbb eax, eax
inc edi
and eax, ebx
xor eax, [ebp+bb.col0]
dec ecx
mov [edi-2], ax
jz .wend1bpp
dec esi
jnz .do1.3
pop esi
jmp short .do1.2
.wend1bpp:
pop ecx
pop esi
pop ecx
add edi, [ebp+bb.s]
dec ecx
jnz .do1.1
pop eax
ret
.paletteConv:
shr ah, 2
shr eax, 3
shl ax, 5
shr eax, 5
ret

BIN
30_day/gview/bmp.obj Normal file

Binary file not shown.

121
30_day/gview/gview.c Normal file
View File

@@ -0,0 +1,121 @@
#include "apilib.h"
struct DLL_STRPICENV { /* 64KB */
int work[64 * 1024 / 4];
};
struct RGB {
unsigned char b, g, r, t;
};
/* bmp.nasm */
int info_BMP(struct DLL_STRPICENV *env, int *info, int size, char *fp);
int decode0_BMP(struct DLL_STRPICENV *env, int size, char *fp, int b_type, char *buf, int skip);
/* jpeg.c */
int info_JPEG(struct DLL_STRPICENV *env, int *info, int size, char *fp);
int decode0_JPEG(struct DLL_STRPICENV *env, int size, char *fp, int b_type, char *buf, int skip);
unsigned char rgb2pal(int r, int g, int b, int x, int y);
void error(char *s);
void HariMain(void)
{
struct DLL_STRPICENV env;
char filebuf[512 * 1024], winbuf[1040 * 805];
char s[32], *p;
int win, i, j, fsize, xsize, info[8];
struct RGB picbuf[1024 * 768], *q;
/*命令行解析*/
api_cmdline(s, 30);
for (p = s; *p > ' '; p++) { } /*一直读到空格为止*/
for (; *p == ' '; p++) { } /*跳过空格*/
/*文件载入*/
i = api_fopen(p); if (i == 0) { error("file not found.\n"); }
fsize = api_fsize(i, 0);
if (fsize > 512 * 1024) {
error("file too large.\n");
}
api_fread(filebuf, fsize, i);
api_fclose(i);
/*检查文件类型*/
if (info_BMP(&env, info, fsize, filebuf) == 0) {
/*不是BMP */
if (info_JPEG(&env, info, fsize, filebuf) == 0) {
/*也不是JPEG */
api_putstr0("file type unknown.\n");
api_end();
}
}
/*上面其中一个info函数调用成功的话info中包含以下信息 */
/*info[0]文件类型1:BMP、2:JPEG*/
/*info[1]:颜色数信息*/
/*info[2]xsize */
/* info[3] : ysize */
if (info[2] > 1024 || info[3] > 768) {
error("picture too large.\n");
}
/*窗口准备*/
xsize = info[2] + 16;
if (xsize < 136) {
xsize = 136;
}
win = api_openwin(winbuf, xsize, info[3] + 37, -1, "gview");
/*将文件内容转换为图像数据*/
if (info[0] == 1) {
i = decode0_BMP (&env, fsize, filebuf, 4, (char *) picbuf, 0);
} else {
i = decode0_JPEG(&env, fsize, filebuf, 4, (char *) picbuf, 0);
}
/*b_type = 4表示struct RGB格式*/
/*skip设为0即可*/
if (i != 0) {
error("decode error.\n");
}
/*显示*/
for (i = 0; i < info[3]; i++) {
p = winbuf + (i + 29) * xsize + (xsize - info[2]) / 2;
q = picbuf + i * info[2];
for (j = 0; j < info[2]; j++) {
p[j] = rgb2pal(q[j].r, q[j].g, q[j].b, j, i);
}
}
api_refreshwin(win, (xsize - info[2]) / 2, 29, (xsize - info[2]) / 2 + info[2], 29 + info[3]);
/*等待结束*/
for (;;) {
i = api_getkey(1);
if (i == 'Q' || i == 'q') {
api_end();
}
}
}
unsigned char rgb2pal(int r, int g, int b, int x, int y)
{
static int table[4] = { 3, 1, 0, 2 };
int i;
x &= 1; /*判断是偶数还是奇数*/
y &= 1;
i = table[x + y * 2]; /*用于生成中间色的常量*/
r = (r * 21) / 256; /*结果为020*/
g = (g * 21) / 256;
b = (b * 21) / 256;
r = (r + i) / 4; /*结果为05*/
g = (g + i) / 4;
b = (b + i) / 4;
return 16 + r + g * 6 + b * 36;
}
void error(char *s)
{
api_putstr0(s);
api_end();
}

733
30_day/gview/jpeg.c Normal file
View File

@@ -0,0 +1,733 @@
/*
* JPEG decoding engine for DCT-baseline
*
* copyrights 2003 by nikq | nikq::club.
*
*
*/
typedef unsigned char UCHAR;
struct DLL_STRPICENV { int work[16384]; };
typedef struct
{
int elem;
unsigned short code[256];
unsigned char size[256];
unsigned char value[256];
}HUFF;
typedef struct
{
// SOF
int width;
int height;
// MCU
int mcu_width;
int mcu_height;
int max_h,max_v;
int compo_count;
int compo_id[3];
int compo_sample[3];
int compo_h[3];
int compo_v[3];
int compo_qt[3];
// SOS
int scan_count;
int scan_id[3];
int scan_ac[3];
int scan_dc[3];
int scan_h[3];
int scan_v[3];
int scan_qt[3];
// DRI
int interval;
int mcu_buf[32*32*4];
int *mcu_yuv[4];
int mcu_preDC[3];
// DQT
int dqt[3][64];
int n_dqt;
// DHT
HUFF huff[2][3];
// FILE i/o
unsigned char *fp, *fp1;
unsigned long bit_buff;
int bit_remain;
int width_buf;
int base_img[64][64];
/* for dll
JPEG *jpeg = (JPEG *)malloc(sizeof(JPEG) + 256);
*/
int dummy[64];
}JPEG;
/* for 16bit */
#ifndef PIXEL16
#define PIXEL16(r, g, b) ((r) << 11 | (g) << 5 | (b))
/* 0 <= r <= 31, 0 <= g <= 63, 0 <= b <= 31 */
#endif
int info_JPEG(struct DLL_STRPICENV *env, int *info, int size, UCHAR *fp);
int decode0_JPEG(struct DLL_STRPICENV *env, int size, UCHAR *fp, int b_type, UCHAR *buf, int skip);
void jpeg_idct_init(int base_img[64][64]);
int jpeg_init(JPEG *jpeg);
// int jpeg_header(JPEG *jpge);
void jpeg_decode(JPEG *jpeg, unsigned char *rgb,int b_type);
/* ----------------- start main section ----------------- */
int info_JPEG(struct DLL_STRPICENV *env,int *info, int size, UCHAR *fp0)
{
JPEG *jpeg = (JPEG *) (((int *) env) + 128);
jpeg->fp = fp0;
jpeg->fp1 = fp0 + size;
// if (512 + sizeof (JPEG) > 64 * 1024)
// return 0;
if (jpeg_init(jpeg))
return 0;
// jpeg_header(jpeg);
if (jpeg->width == 0)
return 0;
info[0] = 0x0002;
info[1] = 0x0000;
info[2] = jpeg->width;
info[3] = jpeg->height;
/* OK */
return 1;
}
int decode0_JPEG(struct DLL_STRPICENV *env,int size, UCHAR *fp0, int b_type, UCHAR *buf, int skip)
{
JPEG *jpeg = (JPEG *) (((int *) env) + 128);
jpeg->fp = fp0;
jpeg->fp1 = fp0 + size;
jpeg_idct_init(jpeg->base_img);
jpeg_init(jpeg);
// jpeg_header(jpeg);
// if (jpeg->width == 0)
// return 8;
/* decode*/
jpeg->width_buf = skip / (b_type & 0x7f) + jpeg->width;
jpeg_decode(jpeg, buf, b_type);
/* OK */
return 0;
}
// -------------------------- I/O ----------------------------
unsigned short get_bits(JPEG *jpeg, int bit)
{
unsigned char c, c2;
unsigned short ret;
unsigned long buff;
int remain;
buff = jpeg->bit_buff;
remain = jpeg->bit_remain;
while (remain <= 16) {
if (jpeg->fp >= jpeg->fp1) {
ret = 0;
goto fin;
}
c = *jpeg->fp++;
if (c == 0xff) {
if (jpeg->fp >= jpeg->fp1) {
ret = 0;
goto fin;
}
jpeg->fp++; /* 00 skip */
}
buff = (buff << 8) | c;
remain += 8;
}
ret = (buff >> (remain - bit)) & ((1 << bit) - 1);
remain -= bit;
jpeg->bit_remain = remain;
jpeg->bit_buff = buff;
fin:
return ret;
}
// ------------------------ JPEG -----------------
// start of frame
int jpeg_sof(JPEG *jpeg)
{
unsigned char c;
int i, h, v, n;
if (jpeg->fp + 8 > jpeg->fp1)
goto err;
/* fp[2] ‚Í bpp */
jpeg->height = jpeg->fp[3] << 8 | jpeg->fp[4];
jpeg->width = jpeg->fp[5] << 8 | jpeg->fp[6];
n = jpeg->compo_count = jpeg->fp[7]; // Num of compo, nf
jpeg->fp += 8;
if (jpeg->fp + n * 3 > jpeg->fp1)
goto err;
for (i = 0; i < n; i++) {
jpeg->compo_id[i] = jpeg->fp[0];
jpeg->compo_sample[i] = c = jpeg->fp[1];
h = jpeg->compo_h[i] = (c >> 4) & 0x0f;
v = jpeg->compo_v[i] = c & 0x0f;
if (jpeg->max_h < h)
jpeg->max_h = h;
if (jpeg->max_v < v)
jpeg->max_v = v;
jpeg->compo_qt[i] = jpeg->fp[2];
jpeg->fp += 3;
}
return 0;
err:
jpeg->fp = jpeg->fp1;
return 1;
}
// define quantize table
int jpeg_dqt(JPEG *jpeg)
{
unsigned char c;
int i, j, v, size;
if (jpeg->fp + 2 > jpeg->fp1)
goto err;
size = (jpeg->fp[0] << 8 | jpeg->fp[1]) - 2;
jpeg->fp += 2;
if (jpeg->fp + size > jpeg->fp1)
goto err;
while (size > 0) {
c = *jpeg->fp++;
size--;
j = c & 7;
if (j > jpeg->n_dqt)
jpeg->n_dqt = j;
if (c & 0xf8) {
// 16 bit DQT
for (i = 0; i < 64; i++) {
jpeg->dqt[j][i] = jpeg->fp[0];
jpeg->fp += 2;
}
size += -64 * 2;
} else {
// 8 bit DQT
for (i = 0; i < 64; i++)
jpeg->dqt[j][i] = *jpeg->fp++;
size -= 64;
}
}
return 0;
err:
jpeg->fp = jpeg->fp1;
return 1;
}
// define huffman table
int jpeg_dht(JPEG *jpeg)
{
unsigned tc, th;
unsigned code = 0;
unsigned char val;
int i, j, k, num, Li[17];
int len, max_val;
HUFF *table;
if (jpeg->fp + 2 > jpeg->fp1)
goto err;
len = (jpeg->fp[0] << 8 | jpeg->fp[1]) - 2;
jpeg->fp += 2;
while (len > 0) {
if (jpeg->fp + 17 > jpeg->fp1)
goto err;
val = jpeg->fp[0];
tc = (val >> 4) & 0x0f;
th = val & 0x0f;
table = &(jpeg->huff[tc][th]);
num = 0;
k = 0;
for (i = 1; i <= 16; i++) {
Li[i] = jpeg->fp[i];
num += Li[i];
for (j = 0; j < Li[i]; j++)
table->size[k++] = i;
}
table->elem = num;
jpeg->fp += 17;
k=0;
code=0;
i = table->size[0];
while (k < num) {
while (table->size[k] == i)
table->code[k++] = code++;
if (k >= num)
break;
do {
code <<= 1;
i++;
} while (table->size[k] != i);
}
if (jpeg->fp + num > jpeg->fp1)
goto err;
for (k = 0; k < num; k++)
table->value[k] = jpeg->fp[k];
jpeg->fp += num;
len -= 18 + num;
}
return 0;
err:
jpeg->fp = jpeg->fp1;
return 1;
}
int jpeg_init(JPEG *jpeg)
{
unsigned char c;
int r = 0, i;
jpeg->width = 0;
jpeg->mcu_preDC[0] = 0;
jpeg->mcu_preDC[1] = 0;
jpeg->mcu_preDC[2] = 0;
jpeg->n_dqt = 0;
jpeg->max_h = 0;
jpeg->max_v = 0;
jpeg->bit_remain = 0;
jpeg->bit_buff = 0;
jpeg->interval = 0;
// return;
//}
//
//int jpeg_header(JPEG *jpeg)
//{
// unsigned char c;
// int r = 0, i;
for (;;) {
if (jpeg->fp + 2 > jpeg->fp1)
goto err;
if (jpeg->fp[0] != 0xff)
goto err0;
c = jpeg->fp[1];
jpeg->fp += 2;
if (c == 0xd8)
continue; /* SOI */
if (c == 0xd9)
goto err; /* EOI */
if (c == 0xc0)
jpeg_sof(jpeg);
else if (c == 0xc4)
jpeg_dht(jpeg);
else if (c == 0xdb)
jpeg_dqt(jpeg);
else if (c == 0xdd) {
if (jpeg->fp + 4 > jpeg->fp1)
goto err;
jpeg->interval = jpeg->fp[2] << 8 | jpeg->fp[3];
jpeg->fp += 4;
} else if (c == 0xda) {
if (jpeg->fp + 3 > jpeg->fp1)
goto err;
jpeg->scan_count = jpeg->fp[2];
jpeg->fp += 3;
if (jpeg->fp + jpeg->scan_count * 2 > jpeg->fp1)
goto err;
for (i = 0; i < jpeg->scan_count; i++) {
jpeg->scan_id[i] = jpeg->fp[0];
jpeg->scan_dc[i] = jpeg->fp[1] >> 4; // DC Huffman Table
jpeg->scan_ac[i] = jpeg->fp[1] & 0x0F; // AC Huffman Table
jpeg->fp += 2;
}
jpeg->fp += 3; /* 3bytes skip */
goto fin;
} else {
if (jpeg->fp + 2 > jpeg->fp1)
goto err;
jpeg->fp += jpeg->fp[0] << 8 | jpeg->fp[1];
}
}
err:
jpeg->fp = jpeg->fp1;
err0:
r++;
fin:
return r;
}
// MCU decode
void jpeg_decode_init(JPEG *jpeg)
{
int i, j;
for (i = 0; i < jpeg->scan_count; i++) {
// i:scan
for (j = 0; j < jpeg->compo_count; j++) {
// j:frame
if (jpeg->scan_id[i] == jpeg->compo_id[j]) {
jpeg->scan_h[i] = jpeg->compo_h[j];
jpeg->scan_v[i] = jpeg->compo_v[j];
jpeg->scan_qt[i] = jpeg->compo_qt[j];
break;
}
}
// if (j >= jpeg->compo_count)
// return 1;
}
jpeg->mcu_width = jpeg->max_h * 8;
jpeg->mcu_height = jpeg->max_v * 8;
for (i = 0; i < 32 * 32 * 4; i++)
jpeg->mcu_buf[i] = 0x80;
for (i = 0; i < jpeg->scan_count; i++)
jpeg->mcu_yuv[i] = jpeg->mcu_buf + (i << 10);
return;
}
int jpeg_huff_decode(JPEG *jpeg,int tc,int th)
{
HUFF *h = &(jpeg->huff[tc][th]);
int code,size,k,v;
code = 0;
size = 0;
k = 0;
while( size < 16 ){
size++;
v = get_bits(jpeg,1);
if(v < 0){
return v;
}
code = (code << 1) | v;
while(h->size[k] == size){
if(h->code[k] == code){
return h->value[k];
}
k++;
}
}
return -1;
}
void jpeg_idct_init(int base_img[64][64])
{
int u, v, m, n;
int tmpm[8], tmpn[8];
int cost[32];
cost[ 0] = 32768; cost[ 1] = 32138; cost[ 2] = 30274; cost[ 3] = 27246; cost[ 4] = 23170; cost[ 5] = 18205; cost[ 6] = 12540; cost[ 7] = 6393;
cost[ 8] = 0; cost[ 9] = -6393; cost[10] = -12540; cost[11] = -18205; cost[12] = -23170; cost[13] = -27246; cost[14] = -30274; cost[15] = -32138;
for (u = 0; u < 16; u++)
cost[u + 16] = - cost[u];
for (u = 0; u < 8; u++) {
{
int i=u, d=u*2;
if (d == 0)
i = 4;
for (m = 0; m < 8; m++){
tmpm[m] = cost[i];
i=(i+d)&31;
}
}
for (v = 0; v < 8; v++) {
{
int i=v,d=v*2;
if (d == 0)
i=4;
for (n = 0; n < 8; n++){
tmpn[n] = cost[i];
i=(i+d)&31;
}
}
for (m = 0; m < 8; m++) {
for (n = 0; n < 8; n++) {
base_img[u * 8 + v][m * 8 + n] = (tmpm[m] * tmpn[n])>>15;
}
}
}
}
return;
}
void jpeg_idct(int *block, int *dest, int base_img[64][64])
{
int i, j ,k;
for (i = 0; i < 64; i++)
dest[i] = 0;
for (i = 0; i < 64; i++) {
k = block[i];
if(k) {
for (j = 0; j < 64; j++) {
dest[j] += k * base_img[i][j];
}
}
}
for (i = 0; i < 64; i++)
dest[i] >>= 17;
return;
}
int jpeg_get_value(JPEG *jpeg,int size)
{
int val = 0;
if (size) {
val = get_bits(jpeg,size);
if (val < 0)
val = 0x10000 | (0 - val);
else if (!(val & (1<<(size-1))))
val -= (1 << size) - 1;
}
return val;
}
int jpeg_decode_huff(JPEG *jpeg,int scan,int *block, UCHAR *zigzag_table)
{
int size, len, val, run, index;
int *pQt = (int *)(jpeg->dqt[jpeg->scan_qt[scan]]);
// DC
size = jpeg_huff_decode(jpeg,0,jpeg->scan_dc[scan]);
if(size < 0)
return 0;
val = jpeg_get_value(jpeg,size);
jpeg->mcu_preDC[scan] += val;
block[0] = jpeg->mcu_preDC[scan] * pQt[0];
//AC
index = 1;
while(index<64)
{
size = jpeg_huff_decode(jpeg,1,jpeg->scan_ac[scan]);
if(size < 0)
break;
// EOB
if(size == 0)
break;
// RLE
run = (size>>4)&0xF;
size = size & 0x0F;
val = jpeg_get_value(jpeg,size);
if(val>=0x10000) {
return val;
}
// ZRL
while (run-- > 0)
block[ zigzag_table[index++] ] = 0;
block[ zigzag_table[index] ] = val * pQt[index];
index++;
}
while(index<64)
block[zigzag_table[index++]]=0;
return 0;
}
void jpeg_mcu_bitblt(int *src, int *dest, int width,
int x0, int y0, int x1, int y1)
{
int w, h;
int x, y, x2, y2;
w = x1 - x0;
h = y1 - y0;
dest += y0 * width + x0;
width -= w;
for (y = 0; y < h; y++) {
y2 = (y * 8 / h) * 8;
for (x = 0; x < w; x++)
*dest++ = src[y2 + (x * 8 / w)];
dest += width;
}
}
int jpeg_decode_mcu(JPEG *jpeg, UCHAR *zigzag_table)
{
int scan, val;
int unit, i, h, v;
int *p, hh, vv;
int block[64], dest[64];
// mcu_width x mcu_height
for (scan = 0; scan < jpeg->scan_count; scan++) {
hh = jpeg->scan_h[scan];
vv = jpeg->scan_v[scan];
for (v = 0; v < vv; v++) {
for (h = 0; h < hh; h++) {
// ƒuƒƒbƒN(8x8)̃fƒR[ƒh
val = jpeg_decode_huff(jpeg, scan, block, zigzag_table);
// if(val>=0x10000){
// printf("marker found:%02x\n",val);
// }
jpeg_idct(block, dest, jpeg->base_img);
p = jpeg->mcu_buf + (scan << 10);
jpeg_mcu_bitblt(dest, p, jpeg->mcu_width,
jpeg->mcu_width * h / hh, jpeg->mcu_height * v / vv,
jpeg->mcu_width * (h + 1) / hh, jpeg->mcu_height * (v + 1) / vv);
}
}
}
}
// YCrCb=>RGB
int jpeg_decode_yuv(JPEG *jpeg, int h, int v, unsigned char *rgb, int b_type)
{
int x0, y0, x, y, x1, y1;
int *py;
int Y12, V;
int mw, mh, w;
int i;
mw = jpeg->mcu_width;
mh = jpeg->mcu_height;
x0 = h * jpeg->max_h * 8;
y0 = v * jpeg->max_v * 8;
x1 = jpeg->width - x0;
if (x1 > mw)
x1 = mw;
y1 = jpeg->height - y0;
if (y1 > mh)
y1 = mh;
py = jpeg->mcu_buf;
rgb += (y0 * jpeg->width_buf + x0) * (b_type & 0x7f);
w = (jpeg->width_buf - x1) * (b_type & 0x7f);
for (y = 0; y < y1; y++) {
for (x = 0; x < x1; x++) {
int b, g, r;
Y12 = py[0] << 12;
// U = py[1024]; /* pu */
V = py[2048]; /* pv */
/* blue */
b = 128 + ((Y12 - V * 4 + py[1024] /* pu */ * 0x1C59) >> 12);
if (b & 0xffffff00)
b = (~b) >> 24;
/* green */
g = 128 + ((Y12 - V * 0x0B6C) >> 12);
if (g & 0xffffff00)
g = (~g) >> 24;
/* red */
r = 128 + ((Y12 + V * 0x166E) >> 12);
if (r & 0xffffff00)
r = (~r) >> 24;
if (b_type == 0x0004) {
rgb[0] = b;
rgb[1] = g;
rgb[2] = r;
py++;
rgb += 4;
} else if (b_type == 0x0002) {
r &= 0xff;
g &= 0xff;
b &= 0xff;
*(short *) rgb = PIXEL16(r >> 3, g >> 2, b >> 3);
rgb += 2;
}
}
py += mw - x1;
rgb += w;
}
return;
}
#define INIT_ZTABLE(i, b0, b1, b2, b3) *(int *) &zigzag_table[i] = b0 | b1 << 8 | b2 << 16 | b3 << 24
void jpeg_decode(JPEG *jpeg, UCHAR *rgb, int b_type)
{
int h_unit, v_unit;
int mcu_count, h, v;
int val;
unsigned char m;
UCHAR zigzag_table[64];
INIT_ZTABLE( 0, 0, 1, 8, 16); INIT_ZTABLE( 4, 9, 2, 3, 10);
INIT_ZTABLE( 8, 17, 24, 32, 25); INIT_ZTABLE(12, 18, 11, 4, 5);
INIT_ZTABLE(16, 12, 19, 26, 33); INIT_ZTABLE(20, 40, 48, 41, 34);
INIT_ZTABLE(24, 27, 20, 13, 6); INIT_ZTABLE(28, 7, 14, 21, 28);
INIT_ZTABLE(32, 35, 42, 49, 56); INIT_ZTABLE(36, 57, 50, 43, 36);
INIT_ZTABLE(40, 29, 22, 15, 23); INIT_ZTABLE(44, 30, 37, 44, 51);
INIT_ZTABLE(48, 58, 59, 52, 45); INIT_ZTABLE(52, 38, 31, 39, 46);
INIT_ZTABLE(56, 53, 60, 61, 54); INIT_ZTABLE(60, 47, 55, 62, 63);
jpeg_decode_init(jpeg);
h_unit = (jpeg->width + jpeg->mcu_width - 1) / jpeg->mcu_width;
v_unit = (jpeg->height + jpeg->mcu_height - 1) / jpeg->mcu_height;
mcu_count = 0;
for (v = 0; v < v_unit; v++) {
for (h = 0; h < h_unit; h++) {
mcu_count++;
jpeg_decode_mcu(jpeg, zigzag_table);
jpeg_decode_yuv(jpeg, h, v, rgb, b_type & 0x7fff);
if (jpeg->interval > 0 && mcu_count >= jpeg->interval) {
jpeg->bit_remain -= (jpeg->bit_remain & 7);
jpeg->bit_remain -= 8;
jpeg->mcu_preDC[0] = 0;
jpeg->mcu_preDC[1] = 0;
jpeg->mcu_preDC[2] = 0;
mcu_count = 0;
}
}
}
return;
}

1
30_day/gview/make.bat Normal file
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -23,13 +23,13 @@ DEL = del
#默认动作
default :
$(MAKE) ipl20.bin
$(MAKE) ipl10.bin
$(MAKE) haribote.sys
# 镜像文件生成
ipl20.bin : ipl20.nas Makefile
$(NASK) ipl20.nas ipl20.bin ipl20.lst
ipl10.bin : ipl10.nas Makefile
$(NASK) ipl10.nas ipl10.bin ipl10.lst
asmhead.bin : asmhead.nas Makefile
$(NASK) asmhead.nas asmhead.bin asmhead.lst
@@ -75,5 +75,5 @@ clean :
src_only :
$(MAKE) clean
-$(DEL) ipl20.bin
-$(DEL) ipl10.bin
-$(DEL) haribote.sys

View File

@@ -88,16 +88,16 @@ struct GATE_DESCRIPTOR {
void init_gdtidt(void);
void set_segmdesc(struct SEGMENT_DESCRIPTOR *sd, unsigned int limit, int base, int ar);
void set_gatedesc(struct GATE_DESCRIPTOR *gd, int offset, int selector, int ar);
#define ADR_IDT 0x0026f800
#define LIMIT_IDT 0x000007ff
#define ADR_GDT 0x00270000
#define LIMIT_GDT 0x0000ffff
#define ADR_IDT 0x0026f800
#define LIMIT_IDT 0x000007ff
#define ADR_GDT 0x00270000
#define LIMIT_GDT 0x0000ffff
#define ADR_BOTPAK 0x00280000
#define LIMIT_BOTPAK 0x0007ffff
#define AR_DATA32_RW 0x4092
#define AR_CODE32_ER 0x409a
#define AR_LDT 0x0082
#define AR_TSS32 0x0089
#define AR_LDT 0x0082
#define AR_TSS32 0x0089
#define AR_INTGATE32 0x008e
/* int.c */
@@ -288,10 +288,10 @@ void file_loadfile(int clustno, int size, char *buf, int *fat, char *img);
struct FILEINFO *file_search(char *name, struct FILEINFO *finfo, int max);
char *file_loadfile2(int clustno, int *psize, int *fat);
/* bootpack.c */
struct TASK *open_constask(struct SHEET *sht, unsigned int memtotal);
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal);
/* tek.c */
int tek_getsize(unsigned char *p);
int tek_decomp(unsigned char *p, char *q, int size);
/* bootpack.c */
struct TASK *open_constask(struct SHEET *sht, unsigned int memtotal);
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal);

View File

@@ -347,7 +347,6 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
{
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
struct FILEINFO *finfo;
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
char name[18], *p, *q;
struct TASK *task = task_now();
int i, segsiz, datsiz, esp, dathrb, appsiz;
@@ -570,13 +569,13 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
fh = &task->fhandle[i];
reg[7] = 0;
if (i < 8) {
finfo = file_search((char *) ebx + ds_base, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
finfo = file_search((char *) ebx + ds_base,
(struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
if (finfo != 0) {
reg[7] = (int) fh;
fh->buf = (char *) memman_alloc_4k(memman, finfo->size);
fh->size = finfo->size;
fh->pos = 0;
file_loadfile2(finfo->clustno, &fh->size, task->fat);
fh->buf = file_loadfile2(finfo->clustno, &fh->size, task->fat);
}
}
} else if (edx == 22) {

Binary file not shown.

152
30_day/haribote/ipl10.nas Normal file
View File

@@ -0,0 +1,152 @@
; haribote-ipl
; TAB=4
CYLS EQU 10 ; 声明CYLS=10
ORG 0x7c00 ; 指明程序装载地址
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
JMP entry
DB 0x90
DB "HARIBOTE" ; 启动扇区名称8字节
DW 512 ; 每个扇区sector大小必须512字节
DB 1 ; 簇cluster大小必须为1个扇区
DW 1 ; FAT起始位置一般为第一个扇区
DB 2 ; FAT个数必须为2
DW 224 ; 根目录大小一般为224项
DW 2880 ; 该磁盘大小必须为2880扇区1440*1024/512
DB 0xf0 ; 磁盘类型必须为0xf0
DW 9 ; FAT的长度必9扇区
DW 18 ; 一个磁道track有几个扇区必须为18
DW 2 ; 磁头数必2
DD 0 ; 不使用分区必须是0
DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码
DB "HARIBOTEOS " ; 磁盘的名称必须为11字?,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格)
RESB 18 ; 先空出18字节
; 程序主体
entry:
MOV AX,0 ; 初始化寄存器
MOV SS,AX
MOV SP,0x7c00
MOV DS,AX
; 读取磁盘
MOV AX,0x0820
MOV ES,AX
MOV CH,0 ; 柱面0
MOV DH,0 ; 磁头0
MOV CL,2 ; 扇区2
MOV BX,18*2*CYLS-1 ; 要读取的合计扇区数
CALL readfast ; 告诉读取
; 读取完毕跳转到haribote.sys执行
MOV [0x0ff0],CH ; 记录IPL实际读取了多少内容
JMP 0xc200
error:
MOV AX,0
MOV ES,AX
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1 ; 给SI加1
CMP AL,0
JE fin
MOV AH,0x0e ; 显示一个文字
MOV BX,15 ; 指定字符颜色
INT 0x10 ; 调用显卡BIOS
JMP putloop
fin:
HLT ; 让CPU停止等待指令
JMP fin ; 无限循环
msg:
DB 0x0a, 0x0a ; 换行两次
DB "load error"
DB 0x0a ; 换行
DB 0
readfast: ; 使用AL尽量一次性读取数据 从此开始
; ES:读取地址, CH:柱面, DH:磁头, CL:扇区, BX:读取扇区数
MOV AX,ES ; < 通过ES计算AL的最大值 >
SHL AX,3 ; 将AX除以32将结果存入AHSHL是左移位指令
AND AH,0x7f ; AH是AH除以128所得的余数512*128=64K
MOV AL,128 ; AL = 128 - AH; AH是AH除以128所得的余数512*128=64K
SUB AL,AH
MOV AH,BL ; < 通过BX计算AL的最大值并存入AH >
CMP BH,0 ; if (BH != 0) { AH = 18; }
JE .skip1
MOV AH,18
.skip1:
CMP AL,AH ; if (AL > AH) { AL = AH; }
JBE .skip2
MOV AL,AH
.skip2:
MOV AH,19 ; < 通过CL计算AL的最大值并存入AH >
SUB AH,CL ; AH = 19 - CL;
CMP AL,AH ; if (AL > AH) { AL = AH; }
JBE .skip3
MOV AL,AH
.skip3:
PUSH BX
MOV SI,0 ; 计算失败次数的寄存器
retry:
MOV AH,0x02 ; AH=0x02 : 读取磁盘
MOV BX,0
MOV DL,0x00 ; A盘
PUSH ES
PUSH DX
PUSH CX
PUSH AX
INT 0x13 ; 调用磁盘BIOS
JNC next ; 没有出错的话则跳转至next
ADD SI,1 ; 将SI加1
CMP SI,5 ; 将SI与5比较
JAE error ; SI >= 5则跳转至error
MOV AH,0x00
MOV DL,0x00 ; A盘
INT 0x13 ; 驱动器重置
POP AX
POP CX
POP DX
POP ES
JMP retry
next:
POP AX
POP CX
POP DX
POP BX ; 将ES的内容存入BX
SHR BX,5 ; 将BX由16字节为单位转换为512字节为单位
MOV AH,0
ADD BX,AX ; BX += AL;
SHL BX,5 ; 将BX由512字节为单位转换为16字节为单位
MOV ES,BX ; 相当于EX += AL * 0x20;
POP BX
SUB BX,AX
JZ .ret
ADD CL,AL ; 将CL加上AL
CMP CL,18 ; 将CL与18比较
JBE readfast ; CL <= 18则跳转至readfast
MOV CL,1
ADD DH,1
CMP DH,2
JB readfast ; DH < 2则跳转至readfast
MOV DH,0
ADD CH,1
JMP readfast
.ret:
RET
RESB 0x7dfe-$ ; 到0x7dfe为止用0x00填充的指令
DB 0x55, 0xaa

View File

@@ -43,10 +43,8 @@ entry:
MOV CH,0 ; 柱面0
MOV DH,0 ; 磁头0
MOV CL,2 ; 扇区2
readloop:
MOV SI,0 ; 记录失败次数寄存器
retry:
MOV AH,0x02 ; AH=0x02 : 读入磁盘
MOV AL,1 ; 1个扇区
@@ -82,8 +80,9 @@ next:
JMP 0xc200
error:
MOV AX,0
MOV ES,AX
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1 ; 给SI加1
@@ -93,7 +92,6 @@ putloop:
MOV BX,15 ; 指定字符颜色
INT 0x10 ; 调用显卡BIOS
JMP putloop
fin:
HLT ; 让CPU停止等待指令
JMP fin ; 无限循环

View File

@@ -16,8 +16,8 @@ void inthandler2c(int *esp)
return;
}
#define KEYCMD_SENDTO_MOUSE 0xd4
#define MOUSECMD_ENABLE 0xf4
#define KEYCMD_SENDTO_MOUSE 0xd4
#define MOUSECMD_ENABLE 0xf4
void enable_mouse(struct FIFO32 *fifo, int data0, struct MOUSE_DEC *mdec)
{
@@ -31,7 +31,7 @@ void enable_mouse(struct FIFO32 *fifo, int data0, struct MOUSE_DEC *mdec)
io_out8(PORT_KEYDAT, MOUSECMD_ENABLE);
/* 顺利的话ACK(0xfa)会被发送*/
mdec->phase = 0; /* 等待鼠标的0xfa的阶段*/
return;
return;
}
int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat)
@@ -40,13 +40,15 @@ int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat)
/* 等待鼠标的0xfa的阶段 */
if (dat == 0xfa) {
mdec->phase = 1;
}
}
return 0;
}
if (mdec->phase == 1) {
/* 等待鼠标第一字节的阶段 */
mdec->buf[0] = dat;
mdec->phase = 2;
if ((dat & 0xc8) == 0x08) {
mdec->buf[0] = dat;
mdec->phase = 2;
}
return 0;
}
if (mdec->phase == 2) {
@@ -67,7 +69,7 @@ int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat)
}
if ((mdec->buf[0] & 0x20) != 0) {
mdec->y |= 0xffffff00;
}
}
mdec->y = - mdec->y; /* 鼠标的y方向与画面符号相反 */
return 1;
}

View File

@@ -231,7 +231,7 @@ static int tek_decode2(int siz, UCHAR *p, UCHAR *q)
if (dsiz > bsiz || (hed & 0x21) != 0x01)
return 1;
if (hed & 0x40)
tek_getnum_s7s(&p);
tek_getnum_s7s(&p); /* <20>I<EFBFBD>v<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ւ̃|<7C>C<EFBFBD><43><EFBFBD>^<5E><>ǂݔ<C782>΂<EFBFBD> */
st = tek_lzrestore_stk2(p1 - p, p, dsiz, q);
}
return st;
@@ -278,7 +278,7 @@ static int tek_lzrestore_tek5(int srcsiz, UCHAR *src, int outsiz, UCHAR *outbuf)
lp = pb;
pb = wrksiz;
}
wrksiz = 0x180 * sizeof (UINT32) + (0x840 + (0x300 << (lc + lp))) * sizeof (tek_TPRB); /* Å’á15KB, lc+lp=3‚È‚çA36KB */
wrksiz = 0x180 * sizeof (UINT32) + (0x840 + (0x300 << (lc + lp))) * sizeof (tek_TPRB); /* <EFBFBD>Œ<EFBFBD>15KB, lc+lp=3<EFBFBD>Ȃ<EFBFBD>A36KB */
work = (int *) memman_alloc_4k((struct MEMMAN *) MEMMAN_ADDR, wrksiz);
if (work == NULL)
return -1;
@@ -457,7 +457,7 @@ static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int p
for (i = sizeof (struct tek_STR_PRB) / sizeof (tek_TPRB) + (0x300 << (lc + lp)) - 2; i >= 0; i--)
((tek_TPRB *) prb)[i] = 1 << 15;
for (i = 0; i < 32; i++) {
rd->bm[i].lt = (i >= 4);
rd->bm[i].lt = (i >= 4); /* 0..3<EFBFBD>͎<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD> */
rd->bm[i].lt0 = (i < 24) ? 16 * 1024 : 8 * 1024;
rd->bm[i].s &= 0;
rd->bm[i].t = rd->bm[i].m = 5;
@@ -466,7 +466,7 @@ static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int p
if (stk) {
rd->rmsk = -1 << 11;
for (i = 0; i < 32; i++)
rd->bm[i].lt = 0;
rd->bm[i].lt = 0; /* <20>S<EFBFBD>Ď<EFBFBD><C48E><EFBFBD><EFBFBD>Ȃ<EFBFBD> */
for (i = 0; i < 14; i++)
rd->ptbm[i] = &rd->bm[0];
} else {
@@ -493,7 +493,7 @@ static int tek_decmain5(int *work, UCHAR *src, int osiz, UCHAR *q, int lc, int p
rd->bm[22].t = 0; rd->bm[22].m = 1;
prb->repg3 = 0xffff;
if (flags == -2) { /* z1 */
rd->bm[22].lt = 0;
rd->bm[22].lt = 0; /* repg3<67><33>lt<6C><74>0<EFBFBD><30> */
for (i = 0; i < 14; i++)
pt[i] = pt1[i];
} else {

View File

@@ -1,9 +1,9 @@
#include <stdio.h> /* sprintf */
#include <string.h> /* strlen */
#include "apilib.h"
void putstr(int win, char *winbuf, int x, int y, int col, unsigned char *s);
void wait(int i, int timer, char *keyflag);
void setdec8(char *s, int i);
static unsigned char charset[16 * 8] = {
@@ -171,7 +171,7 @@ next_group:
/* hit ! */
score += point;
point++;
sprintf(s, "%08d", score);
setdec8(s, score);
putstr(win, winbuf, 10, 0, 7, s);
if (high < score) {
high = score;
@@ -279,3 +279,15 @@ void wait(int i, int timer, char *keyflag)
}
return;
}
void setdec8(char *s, int i)
/*将i用十进制表示并存入s*/
{
int j;
for (j = 7; j >= 0; j--) {
s[j] = '0' + i % 10;
i /= 10;
}
s[8] = 0;
return;
}

BIN
30_day/mmldata/daigo.mml Normal file

Binary file not shown.

30
30_day/mmldata/daigo.org Normal file
View File

@@ -0,0 +1,30 @@
/* 「交響曲第5番 ハ短調 "運命" op. 67」より Ludwig van Beethoven */
$E"SJIS"; $K"交響曲第5番ハ短調 %"運命%" op.67";
T155Q7L8O4
RGGGE-2.RFFFD4&D1
RGGGQ8E-Q7A-A-A-Q8GQ7>E-E-E-C8&C2<GGG
Q8DQ7A-A-A-Q8GQ7>FFFD8&D2GGF
Q8E-Q7<E-E-FQ8G>Q7GGFQ8E-Q7<E-E-F
Q8GQ7>GGFL4E-RCRG2.L8R<A-A-A-F4&F1
RA-A-A-Q8FQ7DDDQ8<BQ7A-A-A-Q8GQ7<GGG
>>E-A-A-A-Q8FQ7DDDQ8<BQ7A-A-A-Q8GQ7<GGG
>>E-G>CCQ8C2Q7<BBB>DQ8D2Q7CCCE-Q8E-Q7DQ4DF
Q8FQ7EQ4EGQ7GQ7FQ4FA-Q8A-Q7GQ4GB-Q8B-Q7A-Q4A->C
Q8CQ7<BQ4B>DQ7CE-E-E-C<GGGE-C<GGE-CCC<B>>>FDD
<BGFFD<BGFD<B>CCC>>E-E-E-
C<AAAG-E-E-E-C<AAAA4R2R4B-4R4
RB-B-B-E-2F2Q8<B-2>L4B->E-DE-FQ7CQ8CQ7<B-
Q8B->E-DE-FQ7CQ8CQ7<B-Q8>B->E-DE-FQ7CQ8C<B-
Q8<B->CD-Q7CQ8<B->C<B-Q7A-Q8>D-E-FQ7E-
Q8D-E-D-Q7CQ8E-FG-FE-Q7FQ8G-FE-Q7FQ8G-F
E-Q7FQ8G-FE-FG-FG-Q7AL8B-&B-2Q4>C<B-A-
Q8A-Q7GQ4FE-Q8E-Q7DQ4CDQ8FQ7E-Q4<B-G
Q8>DQ7CQ4<A-FQ8>CQ7<B-Q4GE-Q7<B-Q8>>AB-A
B-AB-Q7AQ4B->C<B-A-Q8A-Q7GQ4FE-Q8E-Q7DQ4CD
Q8FQ7E-Q4<B-GQ8>DQ7CQ4<A-FQ8>CQ7<B-Q4GE-
Q7<B->B->B-B-E-GGGE-<B-B-B-GE-E-E-
Q8<B-Q7>DDDQ8E-Q7>GGGE-<B-B-B-GE-E-E-
Q8<B-Q7>B-B-B-B-4R4.B-B-B-B-4R4.>DDDE-4
R1R4

BIN
30_day/mmldata/daiku.mml Normal file

Binary file not shown.

17
30_day/mmldata/daiku.org Normal file
View File

@@ -0,0 +1,17 @@
/* 「交響曲第9番 ニ短調 "合唱" op.125」より Ludwig van Beethoven 尾崎喜八作詞 */
$E"SJIS"; T110L4
O4
$K"晴れたる青空 漂う雲よ"; F+F+GA AGF+E DDEF+ F+.E8E2
$K"小鳥は歌えり 林に森に"; F+F+GA AGF+E DDEF+ E.D8D2
$K"心は爽やか 喜び満ちて"; EEF+D EF+8G8F+D EF+8G8F+E DE<A>
$K"見交わす我らの 明るき笑顔"; F+& F+F+GA AGF+E DDEF+ E.D8D2
O5
$K"花咲く丘べに 憩える友よ"; F+F+GA AGF+E DDEF+ F+.E8E2
$K"吹く風爽やか みなぎる陽射し"; F+F+GA AGF+E DDEF+ E.D8D2
$K"心は穏やか 幸せ溢れ"; EEF+D EF+8G8F+D EF+8G8F+E DE<A>
$K"響くは我らの 喜びの歌"; F+& F+F+GA AGF+E DDEF+ E.D8D2
$K""; R1

BIN
30_day/mmldata/fujisan.mml Normal file

Binary file not shown.

View File

@@ -0,0 +1,15 @@
/* 「富士山」 文部省唱歌 巌谷小波作詞 */
$E"SJIS"; T120L4O4
$K"あたまを雲の上に出し"; G.G8AGEC8D8E2 D.G8GF8E8D2.R
$K"四方の山を見おろして"; G.G8ECA.B8>C<A G.A8G8F8E8D8C2.R
$K"かみなりさまを下に聞く"; D.D8DDC8D8E8F8G2 A.B8>C<AG2.R
$K"富士は日本一の山"; >C2<AGE.E8AG FED.C8C2.R
$K"青空高くそびえ立ち"; G.G8AGEC8D8E2 D.G8GF8E8D2.R
$K"からだに雪の着物着て"; G.G8ECA.B8>C<A G.A8G8F8E8D8C2.R
$K"霞のすそを遠く曳く"; D.D8DDC8D8E8F8G2 A.B8>C<AG2.R
$K"富士は日本一の山"; >C2<AGE.E8AG FED.C8C2.R
$K""; R1R1

BIN
30_day/mmldata/kirakira.mml Normal file

Binary file not shown.

View File

@@ -0,0 +1,13 @@
/* 「きらきら星」 フランス民謡 武鹿悦子作詞 */
$E"SJIS"; T120L4O4
$K"きらきらひかる お空の星よ"; CCGGAAG2 FFEEDDC2
$K"まばたきしては みんなを見てる"; GGFFEED2 GGFFEED2
$K"きらきらひかる お空の星よ"; CCGGAAG2 FFEEDDC2
$K""; R1
$K"きらきらひかる お空の星よ"; CCGGAAG2 FFEEDDC2
$K"みんなの歌が 届くといいな"; GGFFEED2 GGFFEED2
$K"きらきらひかる お空の星よ"; CCGGAAG2 FFEEDDC2
$K""; R1 R1

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

5
30_day/mmlplay/Makefile Normal file
View File

@@ -0,0 +1,5 @@
APP = mmlplay
STACK = 132k
MALLOC = 0k
include ../app_make.txt

1
30_day/mmlplay/make.bat Normal file
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

271
30_day/mmlplay/mmlplay.c Normal file
View File

@@ -0,0 +1,271 @@
#include "apilib.h"
#include <string.h> /* strlen */
int strtol(char *s, char **endp, int base); /*标准函数<stdlib.h> */
void waittimer(int timer, int time);
void end(char *s);
void HariMain(void)
{
char winbuf[256 * 112], txtbuf[100 * 1024];
char s[32], *p, *r;
int win, timer, i, j, t = 120, l = 192 / 4, o = 4, q = 7, note_old = 0;
/*音号与频率mHz的对照表*/
/*例如04A为440Hz即440000 */
/*第16八度的A为1802240Hz即1802240000 */
/*以下为第16八度的列表CB */
static int tonetable[12] = {
1071618315, 1135340056, 1202850889, 1274376125, 1350154473, 1430438836,
1515497155, 1605613306, 1701088041, 1802240000, 1909406767, 2022946002
};
static int notetable[7] = { +9, +11, +0 /* C */, +2, +4, +5, +7 };
/*命令行解析*/
api_cmdline(s, 30);
for (p = s; *p > ' '; p++) { } /*一直读到空格为止*/
for (; *p == ' '; p++) { } /*跳过空格*/
i = strlen(p);
if (i > 12) {
file_error:
end("file open error.\n");
}
if (i == 0) {
end(0);
}
/*准备窗口*/
win = api_openwin(winbuf, 256, 112, -1, "mmlplay");
api_putstrwin(win, 128, 32, 0, i, p);
api_boxfilwin(win, 8, 60, 247, 76, 7);
api_boxfilwin(win, 6, 86, 249, 105, 7);
/*载入文件*/
i = api_fopen(p);
if (i == 0) {
goto file_error;
}
j = api_fsize(i, 0);
if (j >= 100 * 1024) {
j = 100 * 1024 - 1;
}
api_fread(txtbuf, j, i);
api_fclose(i);
txtbuf[j] = 0;
r = txtbuf;
i = 0; /*通常模式*/
for (p = txtbuf; *p != 0; p++) { /*为了方便处理,将注释和空白删去*/
if (i == 0 && *p > ' ') { /*不是空格或换行符*/
if (*p == '/') {
if (p[1] == '*') {
i = 1;
} else if (p[1] == '/') {
i = 2;
} else {
*r = *p;
if ('a' <= *p && *p <= 'z') {
*r += 'A' - 'a'; /*将小写字母转换为大写字母*/
}
r++;
}
} else if (*p == 0x22) {
*r = *p;
r++;
i = 3;
} else {
*r = *p;
r++;
}
} else if (i == 1 && *p == '*' && p[1] == '/') { /*段注释*/
p++;
i = 0;
} else if (i == 2 && *p == 0x0a) { /*行注释*/
i = 0;
} else if (i == 3) { /*字符串*/
*r = *p;
r++;
if (*p == 0x22) {
i = 0;
} else if (*p == '%') {
p++;
*r = *p;
r++;
}
}
}
*r = 0;
/*定时器准备*/
timer = api_alloctimer();
api_inittimer(timer, 128);
/*主体*/
p = txtbuf;
for (;;) {
if (('A' <= *p && *p <= 'G') || *p == 'R') { /*音符、休止符*/
/*计算频率*/
if (*p == 'R') {
i = 0;
s[0] = 0;
} else {
i = o * 12 + notetable[*p - 'A'] + 12;
s[0] = 'O';
s[1] = '0' + o;
s[2] = *p;
s[3] = ' ';
s[4] = 0;
}
p++;
if (*p == '+' || *p == '-' || *p == '#') {
s[3] = *p;
if (*p == '-') {
i--;
} else {
i++;
}
p++;
}
if (i != note_old) {
api_boxfilwin(win + 1, 32, 36, 63, 51, 8);
if (s[0] != 0) {
api_putstrwin(win + 1, 32, 36, 10, 4, s);
}
api_refreshwin(win, 32, 36, 64, 52);
if (28 <= note_old && note_old <= 107) {
api_boxfilwin(win, (note_old - 28) * 3 + 8, 60, (note_old - 28) * 3 + 10, 76, 7);
}
if (28 <= i && i <= 107) {
api_boxfilwin(win, (i - 28) * 3 + 8, 60, (i - 28) * 3 + 10, 76, 4);
}
if (s[0] != 0) {
api_beep(tonetable[i % 12] >> (17 - i / 12));
} else {
api_beep(0);
}
note_old = i;
}
/*音长计算*/
if ('0' <= *p && *p <= '9') {
i = 192 / strtol(p, &p, 10);
} else {
i = l;
}
for (; *p == '.'; ) {
p++;
i += i / 2;
}
i *= (60 * 100 / 48);
i /= t;
if (s[0] != 0 && q < 8 && *p != '&') {
j = i * q / 8;
waittimer(timer, j);
api_boxfilwin(win, 32, 36, 63, 51, 8);
if (28 <= note_old && note_old <= 107) {
api_boxfilwin(win, (note_old - 28) * 3 + 8, 60, (note_old - 28) * 3 + 10, 76, 7);
}
note_old = 0;
api_beep(0);
} else {
j = 0;
if (*p == '&') {
p++;
}
}
waittimer(timer, i - j);
} else if (*p == '<') { /*八度-- */
p++;
o--;
} else if (*p == '>') { /*八度++ */
p++;
o++;
} else if (*p == 'O') { /*八度指定*/
o = strtol(p + 1, &p, 10);
} else if (*p == 'Q') { /* Q参数指定*/
q = strtol(p + 1, &p, 10);
} else if (*p == 'L') { /*默认音长指定*/
l = strtol(p + 1, &p, 10);
if (l == 0) {
goto syntax_error;
}
l = 192 / l;
for (; *p == '.'; ) {
p++;
l += l / 2;
}
} else if (*p == 'T') { /*速度指定*/
t = strtol(p + 1, &p, 10);
} else if (*p == '$') { /*扩展命令*/
if (p[1] == 'K') { /*卡拉OK命令*/
p += 2;
for (; *p != 0x22; p++) {
if (*p == 0) {
goto syntax_error;
}
}
p++;
for (i = 0; i < 32; i++) {
if (*p == 0) {
goto syntax_error;
}
if (*p == 0x22) {
break;
}
if (*p == '%') {
s[i] = p[1];
p += 2;
} else {
s[i] = *p;
p++;
}
}
if (i > 30) {
end("karaoke too long.\n");
}
api_boxfilwin(win + 1, 8, 88, 247, 103, 7);
s[i] = 0;
if (i != 0) {
api_putstrwin(win + 1, 128 - i * 4, 88, 0, i, s);
}
api_refreshwin(win, 8, 88, 248, 104);
}
for (; *p != ';'; p++) {
if (*p == 0) {
goto syntax_error;
}
}
p++;
} else if (*p == 0) {
p = txtbuf;
} else {
syntax_error:
end("mml syntax error.\n");
}
}
}
void waittimer(int timer, int time)
{
int i;
api_settimer(timer, time);
for (;;) {
i = api_getkey(1);
if (i == 'Q' || i == 'q') {
api_beep(0);
api_end();
}
if (i == 128) {
return;
}
}
}
void end(char *s)
{
if (s != 0) {
api_putstr0(s);
}
api_beep(0);
api_end();
}

BIN
30_day/pictdata/fujisan.jpg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
30_day/pictdata/night.bmp Normal file

Binary file not shown.

BIN
30_day/pictdata/night_.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -0,0 +1 @@
command

View File

@@ -0,0 +1 @@
cmd.exe

5
30_day/tview/Makefile Normal file
View File

@@ -0,0 +1,5 @@
APP = tview
STACK = 1024k
MALLOC = 0k
include ../app_make.txt

1
30_day/tview/make.bat Normal file
View File

@@ -0,0 +1 @@
..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

276
30_day/tview/tview.c Normal file
View File

@@ -0,0 +1,276 @@
#include "apilib.h"
#include <stdio.h>
int strtol(char *s, char **endp, int base); /* 标准函数 <stdlib.h> */
char *skipspace(char *p);
void textview(int win, int w, int h, int xskip, char *p, int tab, int lang);
char *lineview(int win, int w, int y, int xskip, unsigned char *p, int tab, int lang);
int puttab(int x, int w, int xskip, char *s, int tab);
void HariMain(void)
{
char winbuf[1024 * 757], txtbuf[240 * 1024];
int w = 30, h = 10, t = 4, spd_x = 1, spd_y = 1;
int win, i, j, lang = api_getlang(), xskip = 0;
char s[30], *p, *q = 0, *r = 0;
/*命令行解析*/
api_cmdline(s, 30);
for (p = s; *p > ' '; p++) { } /*一直读到空格为止*/
for (; *p != 0; ) {
p = skipspace(p);
if (*p == '-') {
if (p[1] == 'w') {
w = strtol(p + 2, &p, 0);
if (w < 20) {
w = 20;
}
if (w > 126) {
w = 126;
}
} else if (p[1] == 'h') {
h = strtol(p + 2, &p, 0);
if (h < 1) {
h = 1;
}
if (h > 45) {
h = 45;
}
} else if (p[1] == 't') {
t = strtol(p + 2, &p, 0);
if (t < 1) {
t = 4;
}
} else {
err:
api_putstr0(" >tview file [-w30 -h10 -t4]\n");
api_end();
}
} else { /*找到文件名*/
if (q != 0) {
goto err;
}
q = p;
for (; *p > ' '; p++) { } /*一直读到空格为止*/
r = p;
}
}
if (q == 0) {
goto err;
}
/*准备窗口*/
win = api_openwin(winbuf, w * 8 + 16, h * 16 + 37, -1, "tview");
api_boxfilwin(win, 6, 27, w * 8 + 9, h * 16 + 30, 7);
/*载入文件*/
*r = 0;
i = api_fopen(q);
if (i == 0) {
api_putstr0("file open error.\n");
api_end();
}
j = api_fsize(i, 0);
if (j >= 240 * 1024 - 1) {
j = 240 * 1024 - 2;
}
txtbuf[0] = 0x0a; /*卫兵用的换行代码*/
api_fread(txtbuf + 1, j, i);
api_fclose(i);
txtbuf[j + 1] = 0;
q = txtbuf + 1;
for (p = txtbuf + 1; *p != 0; p++) { /*为了让处理变得简单删掉0x0d的代码*/
if (*p != 0x0d) {
*q = *p;
q++;
}
}
*q = 0;
/*主体*/
p = txtbuf + 1;
for (;;) {
textview(win, w, h, xskip, p, t, lang);
i = api_getkey(1);
if (i == 'Q' || i == 'q') {
api_end();
}
if ('A' <= i && i <= 'F') {
spd_x = 1 << (i - 'A'); /* 1, 2, 4, 8, 16, 32 */
}
if ('a' <= i && i <= 'f') {
spd_y = 1 << (i - 'a'); /* 1, 2, 4, 8, 16, 32 */
}
if (i == '<' && t > 1) {
t /= 2;
}
if (i == '>' && t < 256) {
t *= 2;
}
if (i == '4') {
for (;;) {
xskip -= spd_x;
if (xskip < 0) {
xskip = 0;
}
if (api_getkey(0) != '4') { /*如果没有按下“4”则处理结束*/
break;
}
}
}
if (i == '6') {
for (;;) {
xskip += spd_x;
if (api_getkey(0) != '6') {
break;
}
}
}
if (i == '8') {
for (;;) {
for (j = 0; j < spd_y; j++) {
if (p == txtbuf + 1) {
break;
}
for (p--; p[-1] != 0x0a; p--) { } /*回溯到上一个字符为0x0a为止*/
}
if (api_getkey(0) != '8') {
break;
}
}
}
if (i == '2') {
for (;;) {
for (j = 0; j < spd_y; j++) {
for (q = p; *q != 0 && *q != 0x0a; q++) { }
if (*q == 0) {
break;
}
p = q + 1;
}
if (api_getkey(0) != '2') {
break;
}
}
}
}
}
char *skipspace(char *p)
{
for (; *p == ' '; p++) { } /*跳过空格*/
return p;
}
void textview(int win, int w, int h, int xskip, char *p, int tab, int lang)
{
int i;
api_boxfilwin(win + 1, 8, 29, w * 8 + 7, h * 16 + 28, 7);
for (i = 0; i < h; i++) {
p = lineview(win, w, i * 16 + 29, xskip, p, tab, lang);
}
api_refreshwin(win, 8, 29, w * 8 + 8, h * 16 + 29);
return;
}
char *lineview(int win, int w, int y, int xskip, unsigned char *p, int tab, int lang)
{
int x = - xskip;
char s[130];
for (;;) {
if (*p == 0) {
break;
}
if (*p == 0x0a) {
p++;
break;
}
if (lang == 0) { /* ASCII */
if (*p == 0x09) {
x = puttab(x, w, xskip, s, tab);
} else {
if (0 <= x && x < w) {
s[x] = *p;
}
x++;
}
p++;
}
if (lang == 1) { /* SJIS */
if (*p == 0x09) {
x = puttab(x, w, xskip, s, tab);
p++;
} else if ((0x81 <= *p && *p <= 0x9f) || (0xe0 <= *p && *p <= 0xfc)) {
/*全角字符*/
if (x == -1) {
s[0] = ' ';
}
if (0 <= x && x < w - 1) {
s[x] = *p;
s[x + 1] = p[1];
}
if (x == w - 1) {
s[x] = ' ';
}
x += 2;
p += 2;
} else {
if (0 <= x && x < w) {
s[x] = *p;
}
x++;
p++;
}
}
if (lang == 2) { /* EUC */
if (*p == 0x09) {
x = puttab(x, w, xskip, s, tab);
p++;
} else if (0xa1 <= *p && *p <= 0xfe) {
/*全角字符*/
if (x == -1) {
s[0] = ' ';
}
if (0 <= x && x < w - 1) {
s[x] = *p;
s[x + 1] = p[1];
}
if (x == w - 1) {
s[x] = ' ';
}
x += 2;
p += 2;
} else {
if (0 <= x && x < w) {
s[x] = *p;
}
x++;
p++;
}
}
}
if (x > w) {
x = w;
}
if (x > 0) {
s[x] = 0;
api_putstrwin(win + 1, 8, y, 0, x, s);
}
return p;
}
int puttab(int x, int w, int xskip, char *s, int tab)
{
for (;;) {
if (0 <= x && x < w) {
s[x] = ' ';
}
x++;
if ((x + xskip) % tab == 0) {
break;
}
}
return x;
}

98
LICENSE.txt Normal file
View File

@@ -0,0 +1,98 @@
川合堂许可协议-01 ver.1.0
2000.12.30 H.Kawai (川合秀实)
0.概要
通俗地说:“这是自由软件,使用前使用后都无须支付任何费用,可以自由使用,也可以
复制、修改以及用于商业目的但是作者对软件的bug以及因此所造成的损失不负任何责
任。”
为了保护软件使用者以及软件修改者、参考者的利益,即便作者将来为该软件中所使用的
算法申请专利,也保证不会向使用者收取授权费用。
1.目的
适用于本协议的软件,旨在为公众带来利益,以及为软件技术的进步做出贡献。
2.宗旨
本协议并不代表作者放弃著作权(仅放弃独家复制发布的权利),使用者可以自由复制并
再次发布本软件的一部分甚至全部内容。使用时无须支付任何费用,对本软件的解析、修改
也无须支付任何费用。
适用于本协议的软件,可以无条件地用作商业目的,甚至可以将软件直接有偿出售。
对于以适用于本协议的软件的一部分或全部内容为基础,在此之上所开发的软件(下称“
派生物”),可以赋予任何种类的许可协议。即,派生物的作者可以禁止对派生物进行复制,
也可以只允许派生物以有偿形式发布。派生物的著作权属于该派生物的生成者,适用于本协
议的软件作者不会对其派生物主张著作权。
在派生物的文档中,没有义务对原始软件的作者进行介绍,但这句话,理所当然地,不意
味着禁止这一行为。
在发布派生物时,没有义务取得原始软件作者的同意,但这句话,理所当然地,不意味着
禁止这一行为。
作者不对软件的质量作出任何保证,因此,由于使用本软件所造成的损害,或者没有达到
所期望的结果,作者不负任何责任。
对于适用于本协议的软件中所使用的技术,除了事先取得作者授权的人以外,禁止其他人
对其申请专利。但如果附加了新的技术并生成了派生物,允许对于追加的部分申请专利。作
者在将来有可能对软件中的技术申请专利,但保证不会向派生物以及软件的使用收取授权费
用。本保证不仅适用于申请专利之前所生成的派生物,也适用于专利取得后所生成的派生物。
将解析结果汇总并申请专利,需要事先取得作者的同意,但对于申请专利以外的行为,没
有任何限制。
3.补充
基本上,作者十分欢迎复制本软件。如果要表示对作者的感谢,请将本软件推荐给更多的
人,并复制给他们使用。作者希望有更多的人使用本软件,因此对于复制的行为非常支持。
除此之外,如果可以将使用后的感想发给作者,作者一定会感到更加高兴。
对于本协议所授权的软件,仅修改著作权信息并再次发布的行为,本协议并没有禁止,而
是作为派生物来处理。这并不是一个漏洞。因此,如果你认为有必要仅修改著作权信息并再
次发布本软件,是完全可以这样做的。
除了修复bug、增加新功能等修改行为以外对于为代码添加注释增加易读性、对文档进行
补充等,不会反映在编译产物及运行结果上的修改也同样欢迎。如果生成了这样的派生物,
欢迎和作者联系(但这并不是义务)。
如果你有任何疑问,或者对于制作派生物方面感到缺少某些信息,可以向作者提问。但是,
受作者精力所限可能无法一一进行回复,请大家谅解。对于协议本身漏洞的指摘,请联系作
者或川合堂。
也许,对于本协议所授权的软件中所使用的技术,禁止未经作者允许申请专利这一点,和
日本的专利法是向抵触的(希望大家提出自己的见解)。对此,最初提出本协议的川合秀实
的见解如下。
指定专利法的背景,是因为如果发明者为了保护自己发明所带来的利益,而拒绝将发明的
详情公开,会阻碍科学技术的进步,因此在法律上对于其所公开的内容,在一定时间内给予
独家使用的保护,这是专利法的精神所在。在本协议中,作者并没有故意隐藏发明的详细内
容,因此即便禁止对其申请专利我认为也不违背专利法的精神。相反,不理解本协议精神的
人,如果申请了专利并对原创的软件及派生物收取授权费用,这种担心反倒阻碍了科学技术
的进步。因此,本协议的目的是事先消除这种担心,我认为和专利法是不抵触的。
当然,最稳妥的做法是,作者对原创软件中可以被认作发明的全部内容申请并取得专利,
事前防止其他人来取得相关的专利,但是这对于作者来说负担很大。申请专利的负担和是否
公开软件内容之间必须要有所取舍的话,可能有些人会放弃公开软件内容。这并不是专利法
精神所期待的,也不符合我们的目的(参见“1.目的”)。
此外,当发明的详细内容由于专利法的形式限制没有记述并明确的,由作者以外的人在未
经许可的情况下将其解析并明确的行为,在本协议中是允许的。对于这部分内容,可以无偿
公开,也可以有偿出售。
不过,对于协议所授权的软件中的所有技术,并不能保证在使用时完全避免支付授权费用
的可能性。如果在发布的时间点仍然有效的专利技术,在软件中被使用的话,该专利的所有
者可以要求支付授权费用。本协议所保证的不收取专利授权费用,是针对软件内被认为是新
发明的那一部分技术。
如果需要将本协议适用于自己开发的软件,在事前事后均无须经过作者同意,可任意使用。
如果有任何不方便之处,可以对协议文本进行修改。如需修改协议文本,为了避免歧义,请
同时修改协议的名称。
4.链接
川合堂URL http://www.imasy.org/~mone/kawaido/
川合秀实URL http://www.imasy.org/~kawai/
e-mail kawai@imasy.org

113
README.md
View File

@@ -1,13 +1,15 @@
30dayMakeOS —— OSASK
===========
# 《30天自制操作系统》中文源码 —— OSASK
《30天自制操作系统》源码中文版。自己制作一个操作系统的过程
阅读过程会一边汉化源码,一边执行还有根据一些相关的内容进行代码的书写,欢迎大家交流。
自己制作一个操作系统的过程,阅读过程会一边汉化源码,一边执行还有根据一些相关的内容进行代码的书写,欢迎大家交流。
运行方法,在 `tolset` 中新建一个 `run` 文件夹,把代码拷贝进去,然后根据系统版本运行 `!cons_**.bat`
一般都是使用 `make run` 运行代码。可以直接看书。
一般都是使用 `make run` 运行代码27天开始使用 `make run_full`。可以直接看书。
又或者把tolset里的`z_tools目录` 复制到 本项目目录`30dayMakeOS`下。
## 完成效果
![Screen](Screen.png)
## 内容简介
@@ -23,6 +25,14 @@
渡过这个痛苦的时期,第一周就该结束了。
- [第1天从计算机结构到汇编程序入门](https://github.com/yourtion/30dayMakeOS/releases/tag/Day01)
- [第2天汇编语言学习与Makefile入门](https://github.com/yourtion/30dayMakeOS/releases/tag/Day02)
- [第3天进入32位模式并导入C语言](https://github.com/yourtion/30dayMakeOS/releases/tag/Day03)
- [第4天C语言与画面显示的练习](https://github.com/yourtion/30dayMakeOS/releases/tag/Day04)
- [第5天结构体、文字显示与GDT/IDT初始化](https://github.com/yourtion/30dayMakeOS/releases/tag/Day05)
- [第6天分割编译与中断处理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day06)
- [第7天FIFO与鼠标控制](https://github.com/yourtion/30dayMakeOS/releases/tag/Day07)
### 第二周第8天第14天
一周的苦战还是很有意义的回头一看我们就会发现自己还是斩获颇丰的。这时我们已经基本掌握了C语言的语法连汇编语言的水平也能达到本书的要求了。
@@ -31,12 +41,28 @@
所以这一周我们就边学习算法边慢慢地开发操作系统。不过到了这一阶段,我们就能感觉到基本上不会再受技术问题限制了。
- [第8天鼠标控制与32位模式切换](https://github.com/yourtion/30dayMakeOS/releases/tag/Day08)
- [第9天内存管理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day09)
- [第10天叠加处理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day10)
- [第11天制作窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day11)
- [第12天定时器1](https://github.com/yourtion/30dayMakeOS/releases/tag/Day12)
- [第13天定时器2](https://github.com/yourtion/30dayMakeOS/releases/tag/Day13)
- [第14天高分辨率及键盘输入](https://github.com/yourtion/30dayMakeOS/releases/tag/Day14)
### 第三周第15天第21天
现在我们的技术已经相当厉害了,可以随心所欲地开发自己的操作系统了。首先是要支持多任务,然后是开发命令行窗口,之后就可以着手开发应用程序了。
到本周结束时,就算还不够完备,我们也能拿出一个可以称之为操作系统的软件了。
- [第15天多任务1](https://github.com/yourtion/30dayMakeOS/releases/tag/Day15)
- [第16天多任务2](https://github.com/yourtion/30dayMakeOS/releases/tag/Day16)
- [第17天命令行窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day17)
- [第18天dir命令](https://github.com/yourtion/30dayMakeOS/releases/tag/Day18)
- [第19天应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day19)
- [第20天API](https://github.com/yourtion/30dayMakeOS/releases/tag/Day20)
- [第21天保护操作系统](https://github.com/yourtion/30dayMakeOS/releases/tag/Day21)
### 第四周第22天第28天
在这个阶段,我们可以尽情地给操作系统增加各种各样的功能,同时还可以开发出大量像模像样的应用程序来。
@@ -45,71 +71,18 @@
对了,说起文字才想起来,正好在这个时期可以让我们的操作系统显示文字了。
- [第22天用C语言编写应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day22)
- [第23天图形处理相关](https://github.com/yourtion/30dayMakeOS/releases/tag/Day23)
- [第24天窗口操作](https://github.com/yourtion/30dayMakeOS/releases/tag/Day24)
- [第25天增加命令行窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day25)
- [第26天为窗口移动提速](https://github.com/yourtion/30dayMakeOS/releases/tag/Day26)
- [第27天LDT与库](https://github.com/yourtion/30dayMakeOS/releases/tag/Day27)
- [第28天文件操作与文字显示](https://github.com/yourtion/30dayMakeOS/releases/tag/Day28)
### 免费赠送两天第29天第30天
剩下的两天用来润色加工。这两天我们来做一些之前没来得及做,但做起来既简单又有趣的内容。
## 川合堂许可协议
### 概要
通俗地说:“这是自由软件,使用前使用后都无须支付任何费用,可以自由使用,也可以
复制、修改以及用于商业目的但是作者对软件的bug以及因此所造成的损失不负任何责
任。”
为了保护软件使用者以及软件修改者、参考者的利益,即便作者将来为该软件中所使用的
算法申请专利,也保证不会向使用者收取授权费用。
### 目的
适用于本协议的软件,旨在为公众带来利益,以及为软件技术的进步做出贡献。
#### 宗旨
本协议并不代表作者放弃著作权(仅放弃独家复制发布的权利),使用者可以自由复制并
再次发布本软件的一部分甚至全部内容。使用时无须支付任何费用,对本软件的解析、修改
也无须支付任何费用。
适用于本协议的软件,可以无条件地用作商业目的,甚至可以将软件直接有偿出售。
对于以适用于本协议的软件的一部分或全部内容为基础,在此之上所开发的软件(下称“
派生物”),可以赋予任何种类的许可协议。即,派生物的作者可以禁止对派生物进行复制,
也可以只允许派生物以有偿形式发布。派生物的著作权属于该派生物的生成者,适用于本协
议的软件作者不会对其派生物主张著作权。
在派生物的文档中,没有义务对原始软件的作者进行介绍,但这句话,理所当然地,不意
味着禁止这一行为。
在发布派生物时,没有义务取得原始软件作者的同意,但这句话,理所当然地,不意味着
禁止这一行为。
作者不对软件的质量作出任何保证,因此,由于使用本软件所造成的损害,或者没有达到
所期望的结果,作者不负任何责任。
对于适用于本协议的软件中所使用的技术,除了事先取得作者授权的人以外,禁止其他人
对其申请专利。但如果附加了新的技术并生成了派生物,允许对于追加的部分申请专利。作
者在将来有可能对软件中的技术申请专利,但保证不会向派生物以及软件的使用收取授权费
用。本保证不仅适用于申请专利之前所生成的派生物,也适用于专利取得后所生成的派生物。
将解析结果汇总并申请专利,需要事先取得作者的同意,但对于申请专利以外的行为,没
有任何限制。
### Links
[川合堂](http://www.imasy.org/~mone/kawaido/)
[kawai](http://www.imasy.org/~kawai/)
[豆瓣图书链接](http://book.douban.com/subject/11530329/)
[OSASK计划](http://http://osask.net/)
[OSASK wiki](http://ja.wikipedia.org/wiki/OSASK)
[source code at sourceforge](http://zh.sourceforge.jp/projects/osask/releases/?package_id=10517)
### 工具软件使用
[GNU GPL协议](http://www.gnu.org/licenses/gpl-3.0.html)
[GNU LGPL协议](http://www.gnu.org/licenses/lgpl-3.0.html)
- [第29天压缩与简单的应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day29)
- [第30天高级的应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day30)

BIN
Screen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB