Browse Source

commit most stuff

vampirefrog 4 months ago
parent
commit
c267899068
39 changed files with 13437 additions and 302 deletions
  1. 2
    2
      Makefile
  2. 1
    1
      docs/bioswork.txt
  3. 17
    0
      docs/cmp.txt
  4. 30
    0
      docs/code.txt
  5. 74
    0
      docs/dis.txt
  6. 10
    7
      docs/doscall.txt
  7. 15
    15
      docs/iocscall.txt
  8. 444
    0
      docs/kaiseki.txt
  9. 110
    123
      docs/programmers.txt
  10. 9
    0
      fake_human.inc
  11. 72
    0
      fake_human.s
  12. 25
    0
      fake_ipl.inc
  13. 184
    0
      fake_ipl.s
  14. 115
    48
      main.c
  15. 1
    1
      musashi/m68kconf.h
  16. 6
    3
      musashi/m68kcpu.c
  17. 6
    24
      musashi/m68kcpu.h
  18. 1
    1
      okim6258.c
  19. 2
    0
      tests/Makefile
  20. 203
    0
      tests/filelist.s
  21. 74
    0
      tests/oki4.s
  22. 0
    0
      tests/opmlib.s
  23. 50
    0
      tests/pcm8_1.s
  24. 168
    0
      tests/pcm8_2.s
  25. 11549
    0
      tests/pcm8en.s
  26. BIN
      tests/piano-c4.adp
  27. BIN
      tests/piano-e4.adp
  28. BIN
      tests/piano-g4.adp
  29. 0
    3
      tests/print.s
  30. 26
    0
      tests/startup.s
  31. 2
    0
      tests/tools.h
  32. 107
    0
      tests/tools.s
  33. 52
    25
      v68.c
  34. 21
    16
      v68.h
  35. 3
    0
      v68doscall.h
  36. 5
    0
      v68fecall.h
  37. 10
    6
      v68human.c
  38. 42
    26
      v68periph.c
  39. 1
    1
      v68periph.h

+ 2
- 2
Makefile View File

@@ -13,7 +13,7 @@ musashi/m68kmake: musashi/m68kmake.o
13 13
 	gcc $^ -o $@
14 14
 
15 15
 v68: main.o tools.o v68.o v68ipl.o v68io.o v68periph.o v68human.o v68doscall.o v68iocscall.o v68fecall.o sjis.o sjis_unicode.o utf8.o ym2151.o dmac.o okim6258.o vgm.o $(MUSASHIOBJS) $(MUSASHIGENOBJS) fake_ipl.inc fake_human.inc
16
-	gcc $(filter %.o,$^) $(shell pkg-config --libs ao)  -lm -o $@
16
+	gcc -g -ggdb $(filter %.o,$^) $(shell pkg-config --libs ao)  -lm -o $@
17 17
 
18 18
 v68human.o: v68human.c fake_human.inc
19 19
 
@@ -50,7 +50,7 @@ test-mem: test-mem.o v68.o v68human.o v68opm.o v68io.o v68doscall.o v68fecall.o
50 50
 	gcc $^ -lao -lm -o $@
51 51
 
52 52
 %.o: %.c
53
-	gcc -g -Wall $(shell pkg-config --cflags ao) -c $< -o $@
53
+	gcc -g -ggdb -Wall $(shell pkg-config --cflags ao) -c $< -o $@
54 54
 
55 55
 clean:
56 56
 	rm -f v68 xinfo xdump sjis2utf8 *.o musashi/*.o $(patsubst %.c,musashi/%.c,$(MUSASHIGENCFILES)) ay.js *.wasm *.map test

+ 1
- 1
docs/bioswork.txt View File

@@ -36,7 +36,7 @@ $944	 1.l	〃		Start address of plane
36 36
 $948	 1.l	Text display start address offset
37 37
 $94c	 1.l	Start address of soft keyboard drawing plane(X68000 only)
38 38
 $950	 1.w	〃		Indicates the X coordinate
39
-$952	 1.w	〃		    
39
+$952	 1.w	〃		    Y
40 40
 $954	 1.w	Text clipping range (X minimum value)
41 41
 $956	 1.w	〃			(Y minimum value)
42 42
 $958	 1.w	〃			(X maximum value + 1)

+ 17
- 0
docs/cmp.txt View File

@@ -0,0 +1,17 @@
1
+CMP A,B         signed          unsigned
2
+-------         ------          --------
3
+B < A           BLT             BLO (or BCS)
4
+B <= A          BLE             BLS
5
+B = A           BEQ             BEQ
6
+B <> A          BNE             BNE
7
+B > A           BGT             BHI
8
+B >= A          BGE             BHS (or BCC)
9
+
10
+TST A            signed          unsigned
11
+-------          ------          --------
12
+A <  0           BLT (or BMI)    NOP
13
+A <= 0           BLE             BZ (or BEQ)
14
+A =  0           BZ (or BEQ)     BZ (or BEQ)
15
+A <> 0           BNZ (or BNE)    BNZ (or BNE)
16
+A >  0           BGT             BNZ (or BNE)
17
+A >= 0           BGE (or BPL)    BRA

+ 30
- 0
docs/code.txt View File

@@ -0,0 +1,30 @@
1
+        0x  1x  2x  3x  4x  5x  6x  7x  8x  9x  Ax  Bx  Cx  Dx  Ex  Fx
2
+0       NUL DLE SPC 0   @   P   `   p   *1│  │    ー   タ   ミ │  │*2
3
+1       SOH DC1 !   1   A   Q   a   q ┌非│第│。   ア   チ   ム │第│*3
4
+2       STX DC2 "   2   B   R   b   r │漢│一│「   イ   ツ   メ │二│*4
5
+3       ETX DC3 #   3   C   S   c   s │字│水│」   ウ   テ   モ │水│*5
6
+4       EOT DC4 $   4   D   T   d   t ├─┤準│、   エ   ト   ヤ │準│*6
7
+5       ENQ NAK %   5   E   U   e   u │拡│漢│・   オ   ナ   ユ │漢│*6
8
+6       ACK SYN &   6   F   V   f   v │張│字│ヲ   カ   ニ   ヨ │字│
9
+7       BEL ETB '   7   G   W   g   w │外│  │ァ   キ   ヌ   ラ │  │
10
+8       BS  CAN (   8   H   X   h   x │字├─┤ィ   ク   ネ   リ │  │
11
+9       HT  EM  )   9   I   Y   i   y ├─┤第│ゥ   ケ   ノ   ル │  │
12
+A       LF  SUB *   :   J   Z   j   z │第│二│ェ   コ   ハ   レ ├─┤
13
+B       VT  ESC +   ;   K   [   k   { │一│水│ォ   サ   ヒ   ロ │  │
14
+C       FF  FS  ,   <   L   \   l   | │水│準│ャ   シ   フ   ワ │外│
15
+D       CR  GS  -   =   M   ]   m   } │準│漢│ュ   ス   ヘ   ン │字│
16
+E       SO  RS  .   >   N   ^   n   ~ │漢│字│ョ   セ   ホ   ゙ │  │
17
+F       SI  US  /   ?   O   _   o  DEL│字├─┘ッ   ソ   マ   ゚ └─┘
18
+
19
+*1 $80xx:Hankaku character (Hiragana)
20
+*2 $f0xx:Superscript ¼ angle character (Katakana)
21
+*3 $f1xx:           〃                  (Hiragana)
22
+*4 $f2xx:Subscript 1/4-way character (Katakana)
23
+*5 $f3xx:           〃               (Hiragana)
24
+*6 $f4xx,$f5xx:Half-width word
25
+
26
+非漢字       = Non-Chinese characters
27
+拡張外字     = Extended external characters
28
+第一水準漢字 = First level Chinese character
29
+第二水準漢字 = Second level Chinese character
30
+外字         = External character

+ 74
- 0
docs/dis.txt View File

@@ -0,0 +1,74 @@
1
+Source Code Generator for X680x0 (MinGW cross) version 3.16
2
+Copyright (C)1989-1992 K.Abe, 1994-1997 R.ShimiZu, 2010-05-25 Tachibana.
3
+usage: dis [option] Execution file name [Output file name]
4
+option:
5
+	-a[num]		num Comment out addresses for each line (every 5 lines if num is omitted)
6
+	-b num		Relative branch instruction size output (0: Auto 1: Always omitted 2: Always attached)
7
+	-c		Do not perform label check
8
+	-d		Specified at the time of device driver
9
+	-e[file]	Output of label file
10
+	-f		Do not check the indefinite byte of byte manipulation instruction ($00 or $ff?)
11
+	-g[file]	Read label file
12
+	-h		Pay attention to the address following $4e75(rts) in the data area
13
+	-i		Even if there is an undefined instruction at the branch destination, it is not regarded as a data area
14
+	-j		Do not regard instructions that address errors will occur as undefined instructions
15
+	-k		We assume that there is no label pointing in the instruction
16
+	-l		I will not search severely until I can not find the program area
17
+	-m 680x0[,...]	Specify MPU to be disassembled (68000-68060, 680x0)
18
+	-m 68851	68851 Enable instruction (valid only when -m 68020 is specified)
19
+	-m 6888x[,ID]	Specify valid FPCP and its ID (68881/68882 ID = 0 - 7, default 1)
20
+	-n num		Minimum length to judge as a character string 0 if not determined (Initial value = 3)
21
+	-o num		Number of digits in character string area (1 ≦ num ≦ 80 initial value = 60)
22
+	-p		The program area in the data area is not discriminated
23
+	-q[num]		Do not output message ([0]: normal 1: information about table is not output)
24
+	-r		Add a hexadecimal comment to a character string
25
+	-s[num]		Output of symbol table ([0]: not 1: [normal] 2: all)
26
+	-u[num]		Unused A, F line trap is not regarded as an undefined instruction (num = 1 SX-Window compatible)
27
+	-v		Output a simple disassemble list
28
+	-w num		Number of horizontal bytes in the data area (1 ≦ num ≦ 32 initial value = 8)
29
+	-x		Append the actual opcode with a hexadecimal comment
30
+	-y		Do not check whether all data areas are program areas
31
+	-z base,exec	We consider the executable file as a binary file from base and parse it from exec
32
+
33
+	-A		Change cmpi, movea etc to cmp, move etc.
34
+	-B		Breaking a line even after bra
35
+	-C[num]		Colon after the label (0: not attached 1: 1 for every [2]: normal 3: 2 for all)
36
+	-D		You can also accept programs in the data section
37
+	-E		Do not check rewriting of indefinite bytes of byte manipulation instruction
38
+	-F		Output dbra, fdbra as dbf, fdbf
39
+	-G		Analyze the program that puts the argument immediately after the subroutine call
40
+	-I		Displays the address of the label to be inserted in the command
41
+	-K char		Use char as a comment character
42
+	-L char		Use char as the first character of label name
43
+	-M		cmpi, move, addi.b, subi.b Add comments to #imm and pack, unpk
44
+	-N		If size is default, it does not
45
+	-P num		Enable software emulation instruction (bit specification, initial value = 3)
46
+		+1	Enable unimplemented floating point instructions
47
+		+2	Enable unimplemented integer instructions
48
+	-R num		Specification of check item of unused field (bit designation, initial value = 15)
49
+		+1	Check unused register fields in mulu.l, muls.l, ftst.x
50
+		+2	Check for suppressed register fields in extended addressing
51
+		+4	Check scaling against suppressed index register
52
+		+8	Check size specification (.l) for suppressed index register
53
+	-S[num]		Divide the output file every num KB (if num is omitted, 64 KB)
54
+	-T[file]	Read table description file
55
+	-U		Output mnemonic in capital letters
56
+	-V num		Display of cause of backtrack (0: Disable [1]: Program area 2: all areas)
57
+	-W num		The minimum number of bytes to output the same data in. Dcb. If 0, it is not compressed (initial value = 64)
58
+	-X		Output hexadecimal numbers in upper case
59
+	-Y		Search the include file from the current directory
60
+	-Z[num]		Zero suppression of hexadecimal number ([0]: normal 1: omitted optional '$' omitted)
61
+
62
+	--include-XXX-mac=file	Specifying the include file(XXX = doscall,iocscall,fefunc)
63
+	--exclude-XXX-mac	Do not read include files
64
+	--header=file	Specifying header files(Override environment variable dis_header)
65
+	--(no-)fpsp	Make the unimplemented floating point instruction [Enable] (invalid)
66
+	--(no-)isp	Make unimplemented integer instruction [Enable] (invalid)
67
+	--no-fpu	Invalidate the internal FPU instruction (specified after -m68040 to 68060)
68
+	--no-mmu	Invalidate the built-in MMU instruction (specified after -m68030 to 68060)
69
+	--sp		Write a7 register as 'sp' (--a7 by default)
70
+	--old-syntax	Output addressing as old notation (--new-syntax by default)
71
+	--(in)real	Output floating point in [real notation] (internal expression)
72
+	--overwrite	Overwrite file unconditionally
73
+	--version	Display version
74
+	--help		Display usage

+ 10
- 7
docs/doscall.txt View File

@@ -124,10 +124,13 @@ $fffe   _TIME_PR    Timer counter value acquisition
124 124
 $ffff   _CHANGE_PR  Abandonment of execution rights
125 125
 
126 126
 
127
-note    Calls placed in $ ff 50 to $ ff 7f in Human 68k version 2 were moved to $ ff 80 to $ ffaf in verion 3 and later.
127
+note    Calls placed in $ff50 to $ff7f in Human 68k version 2 were moved to
128
+        $ff80 to $ffaf in verion 3 and later.
128 129
 
129
-	Processing address of calls of $fff5 to $fff7, $fffa ~ $fffe can not be changed (ignored).
130
-	$fff8, $ffff is executed after the original processing is normally completed. $fff9 is called each time one thread is deleted.
130
+        Processing address of calls of $fff5 to $fff7, $fffa~$fffe can not be
131
+        changed (ignored). $fff8, $ffff is executed after the original
132
+        processing is normally completed. $fff9 is called each time one thread
133
+        is deleted.
131 134
 
132 135
 ==============================================================================
133 136
 
@@ -1360,12 +1363,12 @@ Ret	Processing address of specified vector
1360 1363
 
1361 1364
 ==============================================================================
1362 1365
 
1363
-$ff36	_DSKFRE		ディスクの残り容量を得る
1366
+$ff36	_DSKFRE		Get the remaining capacity of the disk
1364 1367
 
1365
-Arg	DRIVE.w		ドライブ番号
1366
-	BUFFER.l	バッファのポインタ
1368
+Arg	DRIVE.w		Drive number
1369
+	BUFFER.l	Buffer pointer
1367 1370
 
1368
-Ret	使用可能なバイト数(最大 2GB、負数ならError code)
1371
+Ret	Number of available bytes(2GB maximum、If it is a negative number, Error code)
1369 1372
 
1370 1373
 	DRIVE で指定したドライブのディスクの残り容量を調べ、結果を BUFFER で指
1371 1374
 	定した 8 バイトのバッファに書き込む.

+ 15
- 15
docs/iocscall.txt View File

@@ -2490,25 +2490,25 @@ Ret	a1.l	次のアドレス
2490 2490
 
2491 2491
 ==============================================================================
2492 2492
 
2493
-$8a	_DMAMOVE	DMA 転送
2493
+$8a	_DMAMOVE	DMA transfer
2494 2494
 
2495
-Arg	d1.b	モード
2496
-		bit    7	方向(0:a1からa2 1:a2からa1)
2497
-		bit 3〜2	MAC(0:a1固定 1:a1++ 2:a1-- 3:指定禁止)
2498
-		bit 1〜0	DAC(0:a2固定 1:a2++ 2:a2-- 3:指定禁止)
2499
-	d2.l	転送バイト数
2500
-	a1.l	転送元アドレス
2501
-	a2.l	転送先
2495
+Arg	d1.b	mode
2496
+		bit    7	direction(0:From a1 to a2 1:From a2 to a1)
2497
+		bit 3〜2	MAC(0:A1 fixed 1:a1++ 2:a1-- 3:Designated prohibition)
2498
+		bit 1〜0	DAC(0:A2 fixed 1:a2++ 2:a2-- 3:Designated prohibition)
2499
+	d2.l	Bytes Transferred
2500
+	a1.l	Source address
2501
+	a2.l	Forwarding destination
2502 2502
 
2503
-Ret	d0/d2/a1/a2 は内容が保証されない.
2503
+Content is not guaranteed for Ret d 0 / d 2 / a 1 / a 2.
2504 2504
 
2505
-	バイト単位で DMA 転送を行なう.
2506
-	$ff00 バイト以上転送する場合はすぐに戻ってこない.
2507
-	DMA が使用不可能であれば、使用可能になるまで待つ.
2505
+	DMA transfer is performed in byte units. When transferring more than $ff00
2506
+	bytes, it will not return immediately. When DMA is unusable, wait until it
2507
+	becomes available.
2508 2508
 
2509
-	IOCS _DMAMOVE、_DMAMOV_A、_DMAMOV_L は必ずバイトサイズで転送を行うので、
2510
-	ワードサイズでアクセスしなければならないポート(PCG エリアなど)に対して
2511
-	使用しないように注意すること.
2509
+	Since IOCS _DMAMOVE, _DMAMOV_A, _DMAMOV_L are always transferred in byte
2510
+	size, be careful not to use for ports (PCG area, etc.) accessed in word
2511
+	size.
2512 2512
 
2513 2513
 ==============================================================================
2514 2514
 

+ 444
- 0
docs/kaiseki.txt View File

@@ -0,0 +1,444 @@
1
+
2
+================================================================================
3
+
4
+・Provisional additional command
5
+
6
+A command provisionally added by hlk evolution.
7
+gcc2 に付属の g2as/g2lk のコマンドとは互換性がない.
8
+試作段階なので変更される可能性がある.
9
+
10
+    4c 01 adr.l                                             ( .ctor text:adr )
11
+    4d 01 adr.l                                             ( .dtor text:adr )
12
+
13
+        対象アドレスを静的コンストラクタ/デストラクタのテーブルに登録する.
14
+        テキストセクション以外は未対応.
15
+
16
+    c0 0c sect_size.l : 'ctor' : 0 : even                           ( header )
17
+    c0 0d sect_size.l : 'dtor' : 0 : even
18
+
19
+        .ctor/.dtor の数*4.
20
+        両方とも 0 なら出力されないが、そうでなければ両方とも出力される.
21
+
22
+    e0 0c                                                          ( .doctor )
23
+    e0 0d                                                          ( .dodtor )
24
+
25
+        静的コンストラクタ/デストラクタを処理するルーチンを含むオブジェクト
26
+        であることを示す.
27
+
28
+
29
+================================================================================
30
+
31
+[ kaiseki.doc ]
32
+
33
+    This material is the result of personal analysis of Satori.
34
+
35
+    この結果は僕個人で調べた物なので、決してシャープ、ハドソン、その他関
36
+    係がありそうな会社、各種団体などには問い合わせないで下さい。:-)
37
+
38
+    何か疑問に思ったこと、知りたいこと等がありましたら、僕に聞いてくださ
39
+    い。できる限りの範囲でお答えしたいと思います。
40
+
41
+    この資料はPDDとします。
42
+
43
+
44
+§ Definition of words
45
+
46
+○ label_no             外部参照またはコモンラベルの登録された時の順番
47
+
48
+○ セクション番号
49
+
50
+    番号の後に * が付いたものは SXhas 用の番号です。
51
+
52
+    fc* rcommon         コモンエリアのラベル
53
+    fd* rlcommon        コモンエリアのラベル
54
+    fe  common          コモンエリアのラベル
55
+    ff  xref            外部参照、または外部定義のラベル
56
+    00  abs             定数
57
+    01  text            テキストセクションのアドレス
58
+    02  data            データセクションのアドレス
59
+    03  bss             ブロックトレースセクションのアドレス
60
+    04  stack           スタックセクションのアドレス
61
+    05* rdata           データセクションのアドレス
62
+    06* rbss            ブロックトレースセクションのアドレス
63
+    07* rstack          スタックセクションのアドレス
64
+    08* rldata          データセクションのアドレス
65
+    09* rlbss           ブロックトレースセクションのアドレス
66
+    0a* rlstack         スタックセクションのアドレス
67
+
68
+○ Added object command
69
+
70
+    47 {fe-ff} : label no.w                                    ( dc.b  label )*
71
+
72
+    A command with '*' at the end like this is what was added in as v 2.00.
73
+    (Why did you have something like this? > Hudson)
74
+
75
+
76
+§ Object file command
77
+
78
+
79
+    00 00                                                              ( end )
80
+
81
+        It always comes at the end of the object file.
82
+
83
+
84
+    10 (size.b - 1) : data (size_byte) : even          ( dc.b  ??,??,....,?? )
85
+
86
+        This is an address independent constant or instruction.
87
+        If it exceeds 256 bytes it will be split.
88
+
89
+
90
+    20 sect.b : 0.l                                         ( change section )
91
+
92
+        Change the section.
93
+        This corresponds to the .text .data quasi-directive of the assembler.
94
+
95
+
96
+    30 00 : size.l                                            ( ds.b  size.l )
97
+
98
+        Secure memory area
99
+        This corresponds to the assembler's .ds.b quasi directive.
100
+
101
+        For the .text .data section, the linker fills that range with 00.
102
+
103
+
104
+    43 {fc-ff} : label no.w                                    ( dc.b  label )
105
+    47 {fe-ff} : label no.w                                    ( dc.b  label )*
106
+    41 {fc-ff} : label no.w                                    ( dc.w  label )
107
+    45 {fe-ff} : label no.w                                    ( dc.w  label )*
108
+    42 {fc-ff} : label no.w                                    ( dc.l  label )
109
+    46 {fc-ff} : label no.w                                    ( dc.l  label )
110
+
111
+        It converts the value of the label of the external reference into the address in the program and writes the value.
112
+
113
+        Other than longwords, it must be a constant.
114
+
115
+        An error occurs when the value exceeds the range of the value to be written respectively
116
+                byte                −$80〜$ff
117
+                word            −$8000〜$ffff
118
+                long    −$80000000〜$ffffffff
119
+
120
+        43 {fc - ff} is the same command. Others are the same.
121
+        adr-adr2 is treated as a constant.
122
+
123
+        47, 45 は、以下の様なソースをアセンブルすると、生成されます。
124
+        (as v2.00のみ)
125
+  ----------------------------------------------------------------------------
126
+        .xref   data_pos
127
+
128
+        move.w  data_pos(a0),d0                 * 45 ff
129
+        move.w  data_pos(a0,d1),d0              * 47 ff
130
+  ----------------------------------------------------------------------------
131
+
132
+
133
+    43 sect.b : adr.l                                       ( dc.b  sect:adr )
134
+    41 sect.b : adr.l                                       ( dc.w  sect:adr )
135
+    42 sect.b : adr.l                                       ( dc.l  sect:adr )
136
+    46 sect.b : adr.l                                       ( dc.l  sect:adr )
137
+
138
+        各エリアでのアドレスをプログラム内のアドレスに変換してその値を書
139
+        き込みます。
140
+
141
+        ロングワード以外は、定数でなければいけません。
142
+
143
+        adr−adr2は定数扱いになります。
144
+
145
+
146
+    40 {fc-ff} : label_no.w                                  ( dc.b  0,label )
147
+
148
+        外部参照のラベルの値をプログラム内のアドレスに変換してその値を書
149
+        き込みます。
150
+
151
+        値が定数でない場合か、−$80〜$ffの範囲を超える場合はエラー
152
+        となります。
153
+
154
+        以下の様なソースをアセンブルすると、このコマンドが生成されます。
155
+  ----------------------------------------------------------------------------
156
+        .xref           test_bit
157
+
158
+        btst.b          #test_bit,(a0)
159
+  ----------------------------------------------------------------------------
160
+
161
+
162
+    40 sect.b : adr.l                                     ( dc.b  0,sect:adr )
163
+
164
+        必ずエラーになります。
165
+	(ベースアドレスが指定されていない場合?)
166
+
167
+
168
+    50 ff      : label no.w : num.l
169
+
170
+        以下の様なソースをアセンブルすると、このコマンドが生成されます。
171
+  ----------------------------------------------------------------------------
172
+        .xref           XREF_LABEL
173
+        move.b          #XREF_LABEL-1,d0
174
+  ----------------------------------------------------------------------------
175
+        Oo patched it with GORRY's point, but it is unknown whether sect.b other than ff exists (1997/01/19).
176
+
177
+
178
+    53 {fc-ff} : label no.w : num.l                        ( dc.b  label+num )
179
+    57 {fe-ff} : label no.w : num.l                        ( dc.b  label+num )*
180
+    51 {fc-ff} : label no.w : num.l                        ( dc.w  label+num )
181
+    55 {fe-ff} : label no.w : num.l                        ( dc.w  label+num )*
182
+    52 {fc-ff} : label no.w : num.l                        ( dc.l  label+num )
183
+    56 {fc-ff} : label no.w : num.l                        ( dc.l  label+num )
184
+
185
+        4xと同様ですがオフセットがつきます。
186
+
187
+
188
+    53 sect.b : adr.l : num.l                           ( dc.b  sect:adr+num )
189
+    51 sect.b : adr.l : num.l                           ( dc.w  sect:adr+num )
190
+    52 sect.b : adr.l : num.l                           ( dc.l  sect:adr+num )
191
+    56 sect.b : adr.l : num.l                           ( dc.l  sect:adr+num )
192
+
193
+        4xと同様ですがオフセットがつきます。
194
+
195
+
196
+    65 sect.b : adr.l : label no.w                    ( dc.w  label-sect:adr )
197
+    69 sect.b : adr.l : label no.w                    ( dc.w  label-sect:adr )*
198
+
199
+        ラベルのアドレスからadrを引いた値を書き込みます。
200
+
201
+        値が定数でない場合か、−$8000〜$7fffの範囲を超える場合
202
+        はエラーとなります。
203
+
204
+        以下の様なソースをアセンブルすると、このコマンドが生成されます。
205
+  ----------------------------------------------------------------------------
206
+        .xref   function
207
+
208
+        bsr     function
209
+  ----------------------------------------------------------------------------
210
+
211
+
212
+    80 {fc-ff} : label no.w                                 ( push  label    )*
213
+    80 00      : num.l                                      ( push  num      )
214
+    80 sect.b  : adr.l                                      ( push  sect:adr )
215
+
216
+        それぞれの値を演算用スタックに積みます。
217
+
218
+
219
+    93 00                                                ( dc.b  (sp) : sp++ )
220
+    91 00                                                ( dc.w  (sp) : sp++ )
221
+    92 00                                                ( dc.l  (sp) : sp++ )
222
+    96 00                                                ( dc.l  (sp) : sp++ )
223
+
224
+        演算用スタックの先頭から値を取り出して書き込みます。
225
+
226
+        値が書き込む値の範囲を超える時はエラーとなります。
227
+        ロングワード以外は、定数でなければいけません。
228
+
229
+
230
+    90 00                                              ( dc.b  0,(sp) : sp++ )
231
+
232
+        演算用スタックの先頭から値を取り出して書き込みます。
233
+
234
+        値が定数でない場合か、−$80〜$ffの範囲を超える場合はエラー
235
+        となります。
236
+
237
+
238
+    99 00                                                ( dc.w  (sp) : sp++ )
239
+
240
+        演算用スタックの先頭から値を取り出して書き込みます。
241
+
242
+        値が定数でない場合か、−$8000〜$7fffの範囲を超える場合
243
+        はエラーとなります。
244
+
245
+
246
+    a0 01                                    ( (sp)   = -(sp)                    )
247
+    a0 02                                    ( (sp)   = (sp)                     )
248
+    a0 03                                    ( (sp)   = .not.(sp)                )
249
+    a0 04                                    ( (sp)   = .high.(sp)               )
250
+    a0 05                                    ( (sp)   = .low.(sp)                )
251
+    a0 06                                    ( (sp)   = .highw.(sp)              )
252
+    a0 07                                    ( (sp)   = .loww.(sp)               )
253
+
254
+    a0 09                                    ( (sp+1) = (sp+1) * (sp)     : sp++ )
255
+    a0 0a                                    ( (sp+1) = (sp+1) / (sp)     : sp++ )
256
+    a0 0b                                    ( (sp+1) = (sp+1) % (sp)     : sp++ )
257
+    a0 0c                                    ( (sp+1) = (sp+1) .shr. (sp) : sp++ )
258
+    a0 0d                                    ( (sp+1) = (sp+1) .shl. (sp) : sp++ )
259
+    a0 0e                                    ( (sp+1) = (sp+1) .asr. (sp) : sp++ )
260
+    a0 0f                                    ( (sp+1) = (sp+1) - (sp)     : sp++ )
261
+    a0 10                                    ( (sp+1) = (sp+1) + (sp)     : sp++ )
262
+    a0 11                                    ( (sp+1) = (sp+1) .eq. (sp)  : sp++ )
263
+    a0 12                                    ( (sp+1) = (sp+1) .ne. (sp)  : sp++ )
264
+    a0 13                                    ( (sp+1) = (sp+1) .lt. (sp)  : sp++ )
265
+    a0 14                                    ( (sp+1) = (sp+1) .le. (sp)  : sp++ )
266
+    a0 15                                    ( (sp+1) = (sp+1) .gt. (sp)  : sp++ )
267
+    a0 16                                    ( (sp+1) = (sp+1) .ge. (sp)  : sp++ )
268
+    a0 17                                    ( (sp+1) = (sp+1) .slt. (sp) : sp++ )
269
+    a0 18                                    ( (sp+1) = (sp+1) .sle. (sp) : sp++ )
270
+    a0 19                                    ( (sp+1) = (sp+1) .sgt. (sp) : sp++ )
271
+    a0 1a                                    ( (sp+1) = (sp+1) .sge. (sp) : sp++ )
272
+    a0 1b                                    ( (sp+1) = (sp+1) .and. (sp) : sp++ )
273
+    a0 1c                                    ( (sp+1) = (sp+1) .xor. (sp) : sp++ )
274
+    a0 1d                                    ( (sp+1) = (sp+1) .or. (sp)  : sp++ )
275
+
276
+        スタック間の演算を行います。addとsub以外は定数しか扱えません。
277
+
278
+
279
+    b2 00      : abs        : label : 0 : even     ( xdef  label = abs       )
280
+    b2 sect.b  : adr.l      : label : 0 : even     ( xdef  label = sect:adr  )
281
+    b2 {fc-fe} : size.l     : label : 0 : even     ( comm  label, size       )
282
+    b2 ff      : label no.l : label : 0 : even     ( xref  label             )
283
+    b0 ff      : label no.l : label : 0 : even     ( xref  label             )
284
+
285
+        ラベルの定義をします。
286
+
287
+        b2 sect.b : size.l : '*'+filename+'*' : 0 : even (sect!=ff)
288
+        の場合はアラインサイズをsizeにします(1997/08/08 立花).
289
+
290
+
291
+    c0 sect.b : sect_size.l : sect_name : 0 : even                  ( header )
292
+
293
+        オブジェクトファイルの先頭に付くヘッダーです。
294
+
295
+
296
+    d0 00 : file_size.l : file_name : 0 : even                   ( file_name )
297
+
298
+        オブジェクトを作った時のファイル名が格納されます。
299
+        必ずしも元のファイル名と同じでなくても構わないはずです。
300
+
301
+        ※size.lは存在しません(1997/08/08 立花).
302
+
303
+
304
+    e0 00 : sect.w : start_adr.l                                 ( start_adr )
305
+
306
+        プログラムの実行アドレスを指定します。
307
+        指定されてない場合は、実行アドレスはプログラムの先頭と見なします。
308
+
309
+        複数存在する場合は、最後に指定したものが有効となります。
310
+
311
+
312
+    e0 01 : file_name : 0 : even                                   ( request )
313
+
314
+        オブジェクトファイルの取り込みを要求します。パスは通りません。
315
+        アセンブラの request と同じです。
316
+
317
+        いくらネストしても構いません、既に取り込んでいた場合は無視します。
318
+
319
+
320
+§ オブジェクトファイルのフォーマット
321
+
322
+    オブジェクトファイルでは、各コマンドが以下の順番に並んでいます。
323
+
324
+        d0 00 : file_size.l  : file name : 0 : even
325
+        c0 01 : text_size.l  : 'text'    : 0 : even
326
+        c0 02 : data_size.l  : 'data'    : 0 : even
327
+        c0 03 : bss_size.l   : 'bss'     : 0 : even
328
+        c0 04 : stack_size.l : 'stack'   : 0 : even
329
+        e0 ??
330
+          .
331
+          .
332
+        e0 ??
333
+        b? ??
334
+          .
335
+          .
336
+        b? ??
337
+
338
+        [その他のコマンド]
339
+
340
+        00 00
341
+
342
+§ アーカイブファイルのフォーマット
343
+
344
+.a の場合
345
+
346
+    D1 00 00 00 00 02                   ヘッダー
347
+    --------------------------------
348
+    +00 object_name + '\0'
349
+    +18 object_size
350
+    +1c object_file_date
351
+    +20 object_file
352
+    +?? object_image
353
+    +??
354
+    --------------------------------    これの繰り返し
355
+
356
+
357
+.l の場合
358
+
359
+    -- header --
360
+    +000000 00 68           ID
361
+    +000002                 lib name
362
+    +00001a                 lib size
363
+    +000020 00 00 00 40     header size
364
+    +000024                 obj info. size
365
+    +000028                 label info. pos
366
+    +00002c                 label info. size
367
+    +000030                 label name info. pos
368
+    +000034                 lanel name info. size
369
+
370
+    -- obj info. --
371
+    +000000                 obj name
372
+    +000018                 label info. pos
373
+    +00001c                 obj image pos
374
+    +000020                 obj image size
375
+    +000024                 obj file date
376
+    +000028                 reserved
377
+                    .
378
+                    .
379
+    +00002f
380
+
381
+    (以下略)
382
+
383
+
384
+§ 実行ファイルのフォーマット
385
+
386
+    [header]
387
+    +00 48 55 00 00 00 00 00 00         'HU'
388
+    +08 exec address
389
+    +0c text section size
390
+    +10 data section size
391
+    +14 bss+common+stack section size
392
+    +18 offset_data size
393
+    +1c symbol_data size
394
+    +20 SCD line number table size
395
+    +24 SCD information size
396
+    +28 SCD name table size
397
+    +2c reserved
398
+
399
+    +40 code, data
400
+    +??
401
+    +?? offset_data
402
+    +??
403
+    +?? symbol_data
404
+    +??
405
+    +?? SCD line number table size
406
+    +??
407
+    +?? SCD information size
408
+    +??
409
+    +?? SCD name table size
410
+    +??
411
+
412
+
413
+§ オフセットデータのフォーマット
414
+
415
+    オフセットデータとは、ロードする際にアロケート情報が必要な場所の情報
416
+    です。
417
+
418
+    詳しくはXファイルをみてもらえれば判ると思います。(手抜き)
419
+
420
+             offset.w                   $00001 <  offset< $10000
421
+        0001 offset.l                   $10000 <= offset
422
+
423
+    offsetが奇数の場合は(offset & ~1)からの1ワードがアロケートされることに
424
+    なっていますが、この形式には対応していません. ワードで納まらないアドレ
425
+    スにロードされた時に正しく動作しないので、対応しても無駄だからです.
426
+    (1997/10/19 立花).
427
+
428
+
429
+§ ラベルデータのフォーマット
430
+
431
+    type address label_name 0 even
432
+                .
433
+                .
434
+    type address label_name 0 even
435
+
436
+    type
437
+    0003        common
438
+    0200        abs, rdata, rbss, rstack, rldata, rlbss, rlstack
439
+    0201        text
440
+    0202        data
441
+    0203        bss
442
+    0204        stack
443
+
444
+(eof)

+ 110
- 123
docs/programmers.txt View File

@@ -286,19 +286,13 @@ $ed001c	1.b	0		起動時のキー LED の状態(電原 OFF 時の状態が
286 286
 				bit 1	ローマ字
287 287
 				bit 0	かな
288 288
 				bit = 0 で消灯、1 で点灯
289
-$ed001d	1.b	16		起動時の画面モード(IOCS CRTMOD の d1)
290
-				ROM IOCS 内のエラー表示ルーチンは 16 のモード
291
-				しか対応していないので、できるだけ 16 以外の値
292
-				は設定しないこと.
293
-				Human68k は常に 16 のモードで起動する.
294
-$ed001e	1.l	0		アラームで起動した時の動作(IOCS _ALARMSET の a1)
295
-				       0:普通に立ち上がる(指定のメディアからブ
296
-					 ート). OFF するまでの時間が -1 以外な
297
-					 ら、指定時間後本体を OFF.
298
-				$01〜$3f:テレビをコントロールする.
299
-					 OFF するまでの時間が -1 なら 1 分後本
300
-					 体のみ OFF. それ以外なら指定時間後本
301
-					 体とテレビを OFF.
289
+$ed001d	1.b	16		Screen mode at startup(IOCS CRTMOD の d1)
290
+				As the error display routine in ROM IOCS only supports 16 modes, do not set values other than 16 as much as possible.
291
+				Human 68k always starts in 16 modes.
292
+$ed001e	1.l	0		Operation when activated by alarm(IOCS _ALARMSET の a1)
293
+				       0:Stand up as usual(Boot from specified media). If the time until turning OFF is other than -1, turn the main unit OFF after the specified time.
294
+				$01〜$3f:Control the TV.
295
+					 OIf the time to FF is -1, only the main body is turned off after 1 minute. Otherwise it turns off the main body and the television after the specified time.
302 296
 				$40〜	:$000040〜$ffffff までのアドレス指定.
303 297
 					 先頭バイトが $60 ならスーパーバイザの
304 298
 					 ままそのアドレスをコールし、そのサブ
@@ -327,126 +321,119 @@ $ed002c	1.b	0		電卓の文字フォント	0:LCD
327 321
 							1:通常のフォント
328 322
 $ed002d	1.b	0		SRAM 使用状態
329 323
 					0:未使用  1:SRAMDISK  2:プログラム
330
-$ed002e	1.w	$0000		テキストパレット 0 のシステム規定値
324
+$ed002e	1.w	$0000		System specification value of text palette 0
331 325
 $ed0030	1.w	$f83e			〃	 1 〃
332 326
 $ed0032	1.w	$ffc0			〃	 2 〃
333 327
 $ed0034	1.w	$fffe			〃	 3 〃
334 328
 $ed0036	1.w	$de6c			〃	 4〜 7 〃
335 329
 $ed0038	1.w	$4022			〃	 8〜15 〃
336
-$ed003a	1.b	3		キーのオートリピートが始まるまでの時間(0〜15)
330
+$ed003a	1.b	3		Time until key auto repeat starts(0〜15)
337 331
 								200+100N[ms]
338
-$ed003b	1.b	2		キーのリピート間隔(0〜15)	 30+5N^2[ms]
339
-$ed003c	1.l	$0008_0000	プリンタタイムアウト時間
340
-$ed0040	1.l	0		SRAM が初期化されてから前回までの積算稼働時間
341
-				本体 OFF 及びソフトウェアリセットごとに積算さ
342
-				れる(分単位).
343
-$ed0044	1.l	0		SRAM が初期化されてから本体が OFF された回数
344
-				本体 OFF ごとに加算される.
345
-$ed0048	1.l	$00ff_dc00	ROMDISK FAT 開始番地(030:$00ff_f400)
332
+$ed003b	1.b	2		Key repeat interval(0〜15)	 30+5N^2[ms]
333
+$ed003c	1.l	$0008_0000	Printer timeout time
334
+$ed0040	1.l	0		Integrated operation time from the initialization of SRAM to the last time It is integrated every time main unit OFF and software reset (in minutes).
335
+$ed0044	1.l	0		Number of times the main body is turned OFF after SRAM is initialized is added for each body OFF.
336
+$ed0048	1.l	$00ff_dc00	ROMDISK FAT start address(030:$00ff_f400)
346 337
 (ROM DISK's BPB)
347
-$ed004c	1.w	1024		1 セクタ当りのバイト数
348
-$ed004e	1.b	1		1 クラスタ当りのセクタ数
349
-$ed004f	1.b	1		FAT 領域の個数
350
-$ed0050	1.w	0		予約領域の個数
351
-$ed0052	1.w	32		ルートディレクトリのエントリ数
352
-$ed0054	1.w	9		全領域のセクタ数(030:3)
353
-$ed0056	1.b	$f9		メディアバイト
354
-$ed0057	1.b	1		FAT 領域 1 個当りのセクタ数
355
-
356
-$ed0058	1.b	0		ROM デバッガの使用($00:OFF $ff:ON)
357
-$ed0059	1.b	0		$7c,$7e,$5c(\~|) の文字変換フラグ
358
-				bit 2	0:| 1:|(破線)
338
+$ed004c	1.w	1024		Number of bytes per sector
339
+$ed004e	1.b	1		Number of sectors per cluster
340
+$ed004f	1.b	1		Number of FAT regions
341
+$ed0050	1.w	0		Number of reserved areas
342
+$ed0052	1.w	32		Number of entries in the root directory
343
+$ed0054	1.w	9		Number of sectors in all areas (030: 3)
344
+$ed0056	1.b	$f9		Media byte
345
+$ed0057	1.b	1		Number of sectors per FAT area
346
+
347
+$ed0058	1.b	0		Using ROM debugger($00:OFF $ff:ON)
348
+$ed0059	1.b	0		$7c,$7e,$5c(\~|) Character conversion flag
349
+				bit 2	0:| 1:|(Dashed line)
359 350
 				bit 1	0: ̄ 1:〜
360 351
 				bit 0	0:¥ 1:\
361
-$ed005a	1.b	0		SASI-HD 接続台数(0〜15)
362
-				指定台数以上は IOCS レベルでエラーになる.
363
-$ed005b	1.b	0		システム予約
352
+$ed005a	1.b	0		Number of SASI-HD connections(0〜15)
353
+				An error occurs at the IOCS level above the specified number.
354
+$ed005b	1.b	0		System reservation
364 355
 (RSDRV.SYS)
365
-$ed005c	1.w	0($4e07)	拡張 RS-232C 設定
366
-$ed005e	1.w	0($4e07)	〃  内容は $ed001a を参照のこと.
367
-$ed0060	1.w	0($4e07)	〃  ただし bit 3〜0 = 8 の場合は 19200bps
356
+$ed005c	1.w	0($4e07)	Extended RS-232C setting
357
+$ed005e	1.w	0($4e07)	〃  See $ ed001a for details.
358
+$ed0060	1.w	0($4e07)	〃  However, if bits 3 to 0 = 8, 19200 bps
368 359
 $ed0062	1.w	0($4e07)	〃
369
-$ed0064	11.b	0		システム予約
360
+$ed0064	11.b	0		System reservation
370 361
 (SCSI)
371
-$ed006f	1.b	0('V')		SCSI 適用フラグ(0:無効 $56='V':有効)
372
-$ed0070	1.b	0		SCSI 関係(bit 7〜4 は X68030 以降で有効)
373
-				bit 7	 DMA 一回あたりの転送語数
374
-						(0:256バイト
375
-						 1:$cc0 で可変、通常 512バイト)
376
-				bit 6	 ブート時のデバイスタイプの無視
377
-						(0:0,4,5,7,$84 のみブート
378
-						 1:デバイスタイプを無視する)
379
-				bit 5	 DMA バーストモード(現在は 0 固定)
380
-						(0:オートリクエスト最大速度
381
-						 1:初回オートリクエスト、以後
382
-						   は外部要求転送)
383
-				bit 4	 転送モード(0:DMA 転送 1:MPU 転送)
384
-				bit 3	 SCSI の種類
385
-						(0:内蔵 1:オプションボード)
386
-				bit 2〜0 本体の ID 番号
387
-$ed0071	1.b	0		SASI フラグ
388
-					SCSI に SASI ディスクを接続した時に
389
-					SASI の ID に対応するビットを 1 にする.
362
+$ed006f	1.b	0('V')		SCSI application flag(0:Disabled $56='V':Effectiveness)
363
+$ed0070	1.b	0		SCSI relationship(bit 7〜4 Valid for X68030 and later)
364
+				bit 7	 Number of words transferred per DMA
365
+						(0:256 bytes
366
+						 1:Variable with $cc0, usually 512 bytes)
367
+				bit 6	 Ignore device type at boot
368
+						(0:0,4,5,7,$84 Boot only
369
+						 1:Ignore device type)
370
+				bit 5	 DMA burst mode(Currently fixed at 0)
371
+						(0:Auto request maximum speed
372
+						 1:Initial auto request, afterwards external request transfer)
373
+				bit 4	 Transfer mode(0:DMA transfer 1:MPU transfer)
374
+				bit 3	 Types of SCSI
375
+						(0:Built in 1:Option board)
376
+				bit 2〜0 ID number of main unit
377
+$ed0071	1.b	0		SASI flag
378
+					When a SASI disk is connected to SCSI, set the bit corresponding to the SASI ID to 1.
390 379
 (SX-WINDOW)
391
-$ed0072	2.b	0('SX')		SX-WINDOW 環境フラグ('SX'で使用中)
392
-$ed0074	1.b	0(6)		マウスポインタの移動量(遅 $03〜$0a 速)
393
-$ed0075	1.b	0(6)		マウスのダブルクリック感覚(短 $00〜$0c 長)
394
-$ed0076	1.b	0(96)		テキストパレット色相:H($00〜$bf)
395
-$ed0077	1.b	0(2)			〃	彩度:S($00〜$1f)
396
-$ed0078	1.b	0(%11111_110)		〃	明度:V0,V1($88〜$ff)
397
-$ed0079	1.b	0(%00_10000_0)			明度:V1,V2,V3($82〜$ba)
398
-$ed007a	1.b	0(%0000_0000)			明度:V3($00〜$e0)
399
-$ed007b	1.b	0(0)		プリンタドライバ(PRTD)ID
380
+$ed0072	2.b	0('SX')		SX-WINDOW environment flag(Busy with 'SX')
381
+$ed0074	1.b	0(6)		Movement amount of mouse pointer(Late $03 to $0a speed)
382
+$ed0075	1.b	0(6)		Double mouse click feeling(短 $00〜$0c 長)
383
+$ed0076	1.b	0(96)		Text Palette Hue:H($00〜$bf)
384
+$ed0077	1.b	0(2)			〃	saturation:S($00〜$1f)
385
+$ed0078	1.b	0(%11111_110)		〃	brightness:V0,V1($88〜$ff)
386
+$ed0079	1.b	0(%00_10000_0)			brightness:V1,V2,V3($82〜$ba)
387
+$ed007a	1.b	0(%0000_0000)			brightness:V3($00〜$e0)
388
+$ed007b	1.b	0(0)		Printer driver(PRTD)ID
400 389
 				0:SHARP CZ 24 ピン	5:EPSON ESC/P24-J84・C
401 390
 				1:EPSON ESC/P24-J83・C	6:ADOBE PostScript
402 391
 				2:NEC PC-PR***		7:CANON LIPS3
403 392
 				3:SHARP CZ 48 ピン	8:EPSON ESC/Page
404 393
 				4:CANON BJ-***
405
-$ed007c	1.b	0(%0010_0011)	bit 7〜4:バージョン番号
394
+$ed007c	1.b	0(%0010_0011)	bit 7〜4:Version number
406 395
 					%0000	SXWIN.X Ver.1.0
407 396
 					%0001	SXWIN.X Ver.1.1
408 397
 					%0010	SXWIN.X Ver.3.0
409
-				bit 3〜0:ファイル保存モード
398
+				bit 3〜0:File save mode
410 399
 				(bit 1:DIRDTOP.SX 保存)
411 400
 				(bit 0:SYSDTOP.SX 保存)
412
-$ed007d	1.b	0(0)		背景ピクチャー(PICT)ID
413
-				0:システム 0	1:システム 1	2:ユーザ定義
401
+$ed007d	1.b	0(0)		Background picture (PICT) ID
402
+				0:System 0	1:System 1	2:User defined
414 403
 $ed007e	1.b	0(0)		SX-WINDOW 画面モード
415
-				bit 7	0:768x512,16 色   1:下位ビットで指定
416
-				bit 6	0:表示画面モード  1:実画面モード
404
+				bit 7	0:768x512,16 colors   1:Designated with lower bits
405
+				bit 6	0:Display screen mode  1:Real screen mode
417 406
 				bit 5〜0:IOCS _CRTMOD での値
418
-$ed007f	1.b	0		システム予約
419
-$ed0080	4.w	0(0,0,0,0)	ウィンドウマージン(左、上、右、下)
420
-$ed0088	8.b	0		システム予約
407
+$ed007f	1.b	0		System reservation
408
+$ed0080	4.w	0(0,0,0,0)	Window margin(Left, up, right, down)
409
+$ed0088	8.b	0		System reservation
421 410
 (X68030)
422
-$ed0090	1.b	0		標準キャッシュ状態(bit=0:OFF 1:ON)
423
-				bit 1	データキャッシュ
424
-				bit 0	命令キャッシュ
425
-$ed0091	1.b	0		起動時サウンド設定(0:OPM 演奏 OFF それ以外:ON)
426
-$ed0092	1.b	0		10MHz 相当のウェイト値(0 の場合は 10 と見なす)
411
+$ed0090	1.b	0		Standard cache state(bit=0:OFF 1:ON)
412
+				bit 1	Data cache
413
+				bit 0	Instruction cache
414
+$ed0091	1.b	0		Sound setting at startup(0:OPM performance OFF other than that:ON)
415
+$ed0092	1.b	0		Weight value equivalent to 10 MHz(0 の場合は 10 と見なす)
427 416
 $ed0093	1.b	0		16MHz 〃	      (0 の場合は 4 と見なす)
428 417
 
429
-$ed0094	4.b	0		システム予約
418
+$ed0094	4.b	0		System reservation
430 419
 (Mach-2)
431
-$ed0098	2.b	0($4368)	Mach-2 マジックナンバ
432
-$ed009a	1.b	0		同期転送の転送周期上限
433
-$ed009b	1.b	0		bit 3=1:パリティチェック
434
-				bit 2=1:限定速度
435
-				bit 1=1:バースト転送
420
+$ed0098	2.b	0($4368)	Mach-2 Magic number
421
+$ed009a	1.b	0		Transfer period upper limit of synchronous transfer
422
+$ed009b	1.b	0		bit 3=1:Parity check
423
+				bit 2=1:Limited speed
424
+				bit 1=1:Burst transfer
436 425
 				bit 0=1:RAM BIOS
437
-$ed009c	4.b	0		未使用
438
-$ed00a0	8.b	0		各 SCSI ID ごとのフラグ
439
-				bit 7=1:同期転送許可
440
-				bit 2〜0:この値が本体 ID と同じときドライブと
441
-					 して認識しない
442
-$ed00a8	1.l	0		512KB 単位でソフト転送を行うビット=1
443
-$ed00ac	1.l	0		512KB 単位で通常バスサイクルを行う(ショートバ
444
-				スサイクルを禁止する)ビット=1
445
-$ed00b0	80.b	0		システム予約
446
-
447
-$ed0100	768.b	0		SRAM プログラムの先頭アドレス
448
-$ed0400	15KB	0		SRAMDISK の先頭アドレス
449
-$ed3fff				SRAM の終わり
426
+$ed009c	4.b	0		Unused
427
+$ed00a0	8.b	0		Flags for each SCSI ID
428
+				bit 7=1:Allow synchronous transfer
429
+				bit 2〜0:When this value is the same as the main body ID, it does not recognize it as a drive
430
+$ed00a8	1.l	0		Soft transfer in units of 512 KB Bits = 1
431
+$ed00ac	1.l	0		Perform normal bus cycle in 512 KB increments (disable short bus cycle) Bit = 1
432
+$ed00b0	80.b	0		System reservation
433
+
434
+$ed0100	768.b	0		Start address of SRAM program
435
+$ed0400	15KB	0		Start address of SRAMDISK
436
+$ed3fff				End of SRAM
450 437
 
451 438
 備考	  SRAM 初期化時 $ed0000〜$ed005a には ROM 中の初期値が書き込まれ、
452 439
 	$ed005b〜$ed00101(X68030 では 〜$ed3fff)は 0 が書き込まれる.
@@ -455,26 +442,26 @@ $ed3fff				SRAM の終わり
455 442
 
456 443
 ・CGROM
457 444
 
458
-address	  font size	type	 count	code(JIS)
459
-$f00000	  全角 16x16	非漢字	  752	High:$21〜$78,Low:$21〜$7e
460
-$f05e00	   〃  16x16	第一水準 3008	     $30〜$4f
461
-$f1d600	   〃  16x16	第二水準 3478	     $50〜$74
462
-$f388c0			(未使用)
463
-$f3a000	 1/4角  8x8	ANK	  256	$00〜$ff
464
-$f3a800	  半角  8x16	〃	  256	
465
-$f3b800	 1/4角 12x12	〃	  256	
466
-$f3d000	  半角 12x24	〃	  256	
467
-$f40000	  全角 24x24	非漢字	  752	High:$21〜$78,Low:$21〜$7e
468
-$f4d380	   〃  24x24	第一水準 3008	     $30〜$4f
469
-$f82180	   〃  24x24	第二水準 3478	     $50〜$74
470
-$fbf3b0			(未使用)
471
-
472
-$xxxxxx	 1/4角  6x12	ANK	  256	$00〜$ff
473
-	このフォントは機種によりアドレスが異なる. 各アドレスは以下の通り.
474
-$ffd018	 X68000 シリーズ
475
-$ffd344	 X68000 XVI
476
-$ffd45e	 X68000 Compact XVI
477
-$fbf400	 X68030 / X68030 Compact
445
+address  font        size      type               count  code(JIS)
446
+$f00000  Full-width  16x16     Non-Chinese chars  752    High:$21〜$78,Low:$21〜$7e
447
+$f05e00   〃         16x16     First level        3008   $30〜$4f
448
+$f1d600   〃         16x16     Second level       3478   $50〜$74
449
+$f388c0              (Unused)
450
+$f3a000  1/4 size    8x8       ANK                256    $00〜$ff
451
+$f3a800  Half size   8x16       〃                256     
452
+$f3b800  1/4 size    12x12      〃                256     
453
+$f3d000  Half size   12x24      〃                256     
454
+$f40000  Full-width  24x24     Non-Chinese chars  752    High:$21〜$78,Low:$21〜$7e
455
+$f4d380   〃         24x24     First level        3008   $30〜$4f
456
+$f82180   〃         24x24     Second level       3478   $50〜$74
457
+$fbf3b0  (Unused)
458
+
459
+$xxxxxx  1/4 angle   6x12      ANK                256    $00〜$ff
460
+        The address differs according to model according to this font. Each address is as follows.
461
+$ffd018 X68000 series
462
+$ffd344 X68000 XVI
463
+$ffd45e X68000 Compact XVI
464
+$fbf400 X68030 / X68030 Compact
478 465
 
479 466
 ==============================================================================
480 467
 

+ 9
- 0
fake_human.inc View File

@@ -0,0 +1,9 @@
1
+0x600c, 0x4661, 0x6b65, 0x2044, 0x4f53, 0x0d0a, 0x0000, 0x2e7c, 
2
+0x0002, 0x1000, 0x6112, 0x33fc, 0xffff, 0x00ea, 0x0008, 0x4e72, 
3
+0x2000, 0x4ef9, 0x0000, 0x681e, 0x43f8, 0x1800, 0x323c, 0x00ff, 
4
+0x22fc, 0x0000, 0x6874, 0x51c9, 0xfff8, 0x21fc, 0x0000, 0x6844, 
5
+0x002c, 0x4e75, 0x48e7, 0xc060, 0x45ef, 0x0012, 0x2252, 0x4280, 
6
+0x3019, 0x2489, 0x0c40, 0xff00, 0x6514, 0x3200, 0xc27c, 0x00ff, 
7
+0xd241, 0xd241, 0x45f8, 0x1800, 0xd5c1, 0x2452, 0x4e92, 0x4cdf, 
8
+0x0603, 0x4e73, 0x4fef, 0x001a, 0x227c, 0x00ea, 0x0000, 0x3280, 
9
+0x4fef, 0xffe6, 0x4e75, 

+ 72
- 0
fake_human.s View File

@@ -0,0 +1,72 @@
1
+;
2
+; Fake HUMAN.SYS
3
+;
4
+; Uses a fake MMIO port to execute the actual DOS stuff
5
+;
6
+
7
+LineFVecAddr       equ $00002c
8
+DOSCallVecTable    equ $001800
9
+DOSWorkCurProcAddr equ $001caa
10
+FakeDOSCallPort    equ $ea0000
11
+FakeEmuCmdPort     equ $ea0008
12
+
13
+.text
14
+
15
+Start:
16
+	bra DOSStart
17
+
18
+HelloString:
19
+	.dc.b 'Fake DOS', $0d, $0a, $00, $00
20
+
21
+DOSStart:
22
+	movea.l #$21000,sp
23
+	bsr SetupDOSCalls
24
+	; Signal to emulator that we're done initializing
25
+	move.w #$ffff, (FakeEmuCmdPort)
26
+@@:
27
+	stop #$2000
28
+	jmp @b
29
+
30
+; Setup DOS call table at $1800
31
+; and the Line F exception handler
32
+SetupDOSCalls:
33
+	lea.l	(DOSCallVecTable),a1
34
+	move.w	#$00ff,d1
35
+@@:
36
+	move.l	#FakeDOSCallHandler,(a1)+ ; Fill all 256 DOS calls with the fake handler
37
+	dbra.w	d1,@b
38
+
39
+	move.l	#LineFExceptionHandler,(LineFVecAddr)
40
+
41
+	rts
42
+
43
+; Catch $Fxxx instructions
44
+LineFExceptionHandler:
45
+	movem.l d0-d1/a1-a2,-(sp)
46
+	lea.l   ($0012,sp),a2  ; Get stack addr of pushed PC
47
+	movea.l (a2),a1        ; Get PC from stack
48
+	clr.l   d0
49
+	move.w  (a1)+,d0       ; Get instruction from (PC)
50
+	move.l  a1, (a2)
51
+	cmpi.w  #$ff00,d0      ; Only process instructions >= $ff00
52
+	bcs     LineFDone
53
+
54
+	move.w  d0, d1
55
+	and.w   #$00ff, d1
56
+	add.w   d1, d1
57
+	add.w   d1, d1
58
+	lea.l   (DOSCallVecTable), a2
59
+	add.l   d1, a2
60
+	move.l  (a2), a2
61
+	jsr     (a2)
62
+
63
+LineFDone:
64
+	movem.l (sp)+,d0-d1/a1-a2
65
+	rte
66
+
67
+FakeDOSCallHandler:
68
+	lea.l (26,sp),sp
69
+	move.l #FakeDOSCallPort, a1
70
+	move.w d0, (a1)
71
+	lea.l (-26,sp),sp
72
+	rts

+ 25
- 0
fake_ipl.inc View File

@@ -0,0 +1,25 @@
1
+0x0000, 0x2000, 0x00ff, 0x0030, 0x00ff, 0x007c, 0x00ff, 0x007c, 
2
+0x00ff, 0x007c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
3
+0x00ff, 0x007c, 0x00ff, 0x007c, 0x0000, 0x0000, 0x0000, 0x0000, 
4
+0x46fc, 0x2700, 0x4ff8, 0x2000, 0x4e70, 0x610c, 0x617e, 0x6100, 
5
+0x00e4, 0x6140, 0x4ef8, 0x6800, 0x43f9, 0x00ff, 0x007c, 0x21c9, 
6
+0x0008, 0x43f9, 0x00ff, 0x007c, 0x21c9, 0x000c, 0x43f9, 0x00ff, 
7
+0x007c, 0x21c9, 0x0010, 0x43f9, 0x00ff, 0x007c, 0x21c9, 0x0020, 
8
+0x43f9, 0x00ff, 0x007c, 0x21c9, 0x0024, 0x4e75, 0x4e72, 0x2000, 
9
+0x60fa, 0x4e73, 0x43f8, 0x0400, 0x323c, 0x00ff, 0x45f9, 0x00ff, 
10
+0x00b4, 0x22ca, 0x51c9, 0xfff6, 0x4e75, 0x48e7, 0x0040, 0xc07c, 
11
+0x00ff, 0xd040, 0xd040, 0x43f8, 0x0400, 0xd3c0, 0x4e91, 0x4cdf, 
12
+0x0200, 0x4e73, 0x33c0, 0x00ea, 0x0004, 0x4e75, 0x43f9, 0x00ff, 
13
+0x0122, 0x21c9, 0x0080, 0x43f9, 0x00ff, 0x0122, 0x21c9, 0x0084, 
14
+0x43f9, 0x00ff, 0x0122, 0x21c9, 0x0088, 0x43f9, 0x00ff, 0x0122, 
15
+0x21c9, 0x008c, 0x43f9, 0x00ff, 0x0122, 0x21c9, 0x0090, 0x43f9, 
16
+0x00ff, 0x0122, 0x21c9, 0x0094, 0x43f9, 0x00ff, 0x0122, 0x21c9, 
17
+0x0098, 0x43f9, 0x00ff, 0x0122, 0x21c9, 0x009c, 0x43f9, 0x00ff, 
18
+0x0122, 0x21c9, 0x00a0, 0x43f9, 0x00ff, 0x009a, 0x21c9, 0x00bc, 
19
+0x4e75, 0x4e73, 0x43f9, 0x00ff, 0x014e, 0x21c9, 0x0118, 0x43f9, 
20
+0x00ff, 0x014e, 0x21c9, 0x0138, 0x43f9, 0x00ff, 0x0150, 0x21c9, 
21
+0x01a8, 0x43f9, 0x00ff, 0x0150, 0x21c9, 0x01ac, 0x4e75, 0x4e73, 
22
+0x2f08, 0x41f9, 0x00e8, 0x40c0, 0x11e8, 0x0001, 0x0c33, 0x4a38, 
23
+0x0c32, 0x6b18, 0x13fc, 0x0001, 0x00e9, 0xa007, 0x13fc, 0x0003, 
24
+0x00e9, 0xa007, 0x13fc, 0x0001, 0x00e9, 0x2001, 0x4a10, 0x50d0, 
25
+0x4238, 0x0c32, 0x205f, 0x4e73, 

+ 184
- 0
fake_ipl.s View File

@@ -0,0 +1,184 @@
1
+;
2
+; Fake IOCS / IPL ROM
3
+;
4
+; The emulator starts execution at $000000
5
+;
6
+
7
+; Some constants
8
+BusErrVecAddr             equ $000008
9
+AddrErrVecAddr            equ $00000c
10
+ImproperOrderVecAddr      equ $000010
11
+PrivilegeViolationVecAddr equ $000020
12
+TraceExceptionVecAddr     equ $000024
13
+Trap0VecAddr              equ $000080
14
+Trap1VecAddr              equ $000084
15
+Trap2VecAddr              equ $000088
16
+Trap3VecAddr              equ $00008C
17
+Trap4VecAddr              equ $000090
18
+Trap5VecAddr              equ $000094
19
+Trap6VecAddr              equ $000098
20
+Trap7VecAddr              equ $00009c
21
+Trap8VecAddr              equ $0000a0
22
+Trap15VecAddr             equ $0000bc
23
+VdispVecAddr              equ $000118
24
+CrtcVecAddr               equ $000138
25
+DMA3IntVecAddr            equ $0001a8
26
+DMA3ErrIntVecAddr         equ $0001ac
27
+IOCSCallVecTable          equ $000400
28
+IOCSWorkDMA3Mode          equ $000c32
29
+IOCSWorkDMA3Err           equ $000c33
30
+DefaultStackAddr          equ $002000
31
+HumanStart                equ $006800
32
+DMA3Regs                  equ $e840c0
33
+I8255ControlWord          equ $e9a007
34
+ADPCMCommand              equ $e92001
35
+FakeIOCSCallPort          equ $ea0004
36
+
37
+.text
38
+
39
+IPLStart:
40
+	.dc.l DefaultStackAddr ; Default stack top
41
+EntryPointPtr
42
+	.dc.l EntryPoint       ; PC at boot
43
+BootBusErrVec:
44
+	.dc.l	DefaultExceptionHandler
45
+BootAddressErrVec:
46
+	.dc.l	DefaultExceptionHandler
47
+BootImproperOrderVec:
48
+	.dc.l	DefaultExceptionHandler
49
+BootDivideBy0Vec:
50
+	.dc.l	$00000000
51
+BootCHKCmdVec:
52
+	.dc.l	$00000000
53
+BootTRAPVccVec:
54
+	.dc.l	$00000000
55
+BootPrivilegeViolationVec:
56
+	.dc.l	DefaultExceptionHandler
57
+BootTraceExceptionVec:
58
+	.dc.l	DefaultExceptionHandler
59
+BootLineAVec:
60
+	.dc.l	$00000000
61
+BootLineFVec:
62
+	.dc.l	$00000000
63
+
64
+EntryPoint:	             ; Boot entry point
65
+	move.w	#$2700,sr
66
+	lea.l	(DefaultStackAddr),a7
67
+	reset
68
+	bsr     SetupExceptions
69
+	bsr     SetupTraps
70
+	bsr     SetupInterrupts
71
+	bsr     SetupIOCSCalls
72
+
73
+	jmp	    HumanStart            ; Go to DOS
74
+
75
+;
76
+; Exceptions
77
+;
78
+SetupExceptions:
79
+	lea.l (DefaultExceptionHandler), a1
80
+	move.l a1, (BusErrVecAddr)
81
+	lea.l (DefaultExceptionHandler), a1
82
+	move.l a1, (AddrErrVecAddr)
83
+	lea.l (DefaultExceptionHandler), a1
84
+	move.l a1, (ImproperOrderVecAddr)
85
+	lea.l (DefaultExceptionHandler), a1
86
+	move.l a1, (PrivilegeViolationVecAddr)
87
+	lea.l (DefaultExceptionHandler), a1
88
+	move.l a1, (TraceExceptionVecAddr)
89
+	rts
90
+
91
+DefaultExceptionHandler:
92
+	stop #$2000
93
+	bra DefaultExceptionHandler
94
+	rte
95
+
96
+;
97
+; IOCS Calls
98
+;
99
+SetupIOCSCalls:
100
+	; Set all 256 IOCS call handlers to the fake handler
101
+	lea.l	(IOCSCallVecTable),a1
102
+	move.w	#$00ff,d1
103
+@@:
104
+	lea.l (FakeIOCSCallHandler), a2
105
+	move.l  a2,(a1)+ ; Fill all 256 DOS calls with the fake handler
106
+	dbra.w	d1,@b
107
+	rts
108
+
109
+FakeTrap15Handler:
110
+	movem.l a1,-(sp)
111
+	and.w   #$00ff, d0
112
+	add.w   d0, d0
113
+	add.w   d0, d0
114
+	lea.l   (IOCSCallVecTable), a1
115
+	add.l   d0, a1
116
+	jsr     (a1)
117
+	movem.l (sp)+,a1
118
+	rte
119
+
120
+FakeIOCSCallHandler:
121
+	move.w  d0, (FakeIOCSCallPort)
122
+	rts
123
+
124
+;
125
+; Traps
126
+;
127
+SetupTraps:
128
+	lea.l (DefaultTrapHandler), a1
129
+	move.l a1, (Trap0VecAddr)
130
+	lea.l (DefaultTrapHandler), a1
131
+	move.l a1, (Trap1VecAddr)
132
+	lea.l (DefaultTrapHandler), a1
133
+	move.l a1, (Trap2VecAddr)
134
+	lea.l (DefaultTrapHandler), a1
135
+	move.l a1, (Trap3VecAddr)
136
+	lea.l (DefaultTrapHandler), a1
137
+	move.l a1, (Trap4VecAddr)
138
+	lea.l (DefaultTrapHandler), a1
139
+	move.l a1, (Trap5VecAddr)
140
+	lea.l (DefaultTrapHandler), a1
141
+	move.l a1, (Trap6VecAddr)
142
+	lea.l (DefaultTrapHandler), a1
143
+	move.l a1, (Trap7VecAddr)
144
+	lea.l (DefaultTrapHandler), a1
145
+	move.l a1, (Trap8VecAddr)
146
+	lea.l (FakeTrap15Handler), a1
147
+	move.l a1, (Trap15VecAddr)
148
+	rts
149
+
150
+DefaultTrapHandler:
151
+	rte
152
+
153
+;
154
+; Interrupts
155
+;
156
+SetupInterrupts:
157
+	lea.l (DefaultIntHandler), a1
158
+	move.l a1, (VdispVecAddr)
159
+	lea.l (DefaultIntHandler), a1
160
+	move.l a1, (CrtcVecAddr)
161
+	lea.l (DMA3Interrupt), a1
162
+	move.l a1, (DMA3IntVecAddr)
163
+	lea.l (DMA3Interrupt), a1
164
+	move.l a1, (DMA3ErrIntVecAddr)
165
+	rts
166
+
167
+DefaultIntHandler:
168
+	rte
169
+
170
+DMA3Interrupt:
171
+	move.l	a0,-(a7)
172
+	lea.l	(DMA3Regs),a0
173
+	move.b	($0001,a0),(IOCSWorkDMA3Err)
174
+	tst.b	(IOCSWorkDMA3Mode)
175
+	bmi.s	@f
176
+	move.b	#$01,(I8255ControlWord)
177
+	move.b	#$03,(I8255ControlWord)
178
+	move.b	#$01,(ADPCMCommand)
179
+@@:
180
+	tst.b	(a0)
181
+	st.b	(a0)
182
+	clr.b	(IOCSWorkDMA3Mode)
183
+	movea.l	(a7)+,a0
184
+	rte

+ 115
- 48
main.c View File

@@ -1,5 +1,6 @@
1 1
 #include <stdio.h>
2 2
 #include <signal.h>
3
+#include <stdlib.h>
3 4
 #include <string.h>
4 5
 #include <sys/types.h>
5 6
 #include <sys/stat.h>
@@ -12,15 +13,34 @@
12 13
 #include "v68io.h"
13 14
 #include "tools.h"
14 15
 
15
-#define BUF_SIZE 4096
16
-#define SAMPLE_RATE 44100
17
-#define V68_CLOCK 16000000
18
-#define V68_RAM 8*1024*1024
16
+#define DEFAULT_CPU_CLOCK   8000000
17
+#define DEFAULT_RAM_SIZE    8 * 1024 * 1024
18
+#define DEFAULT_SAMPLE_RATE 44100
19
+#define DEFAULT_BUFFER_SIZE    4096
20
+
21
+int opt_cpu_clock   = DEFAULT_CPU_CLOCK;
22
+int opt_ram_size    = DEFAULT_RAM_SIZE;
23
+int opt_sample_rate = DEFAULT_SAMPLE_RATE;
24
+int opt_buffer_size = DEFAULT_BUFFER_SIZE;
25
+char *opt_vgm_file  = 0;
26
+int opt_utf8        = 0;
27
+int opt_verbosity   = 0;
28
+int opt_log_calls   = 0;
29
+int opt_dasm        = 0;
30
+char cmd_queue[V68_CMD_QUEUE_LEN][1024];
31
+int cmd_queue_pos;
32
+
33
+void queue_cmd(char *cmdline) {
34
+	if(cmd_queue_pos > V68_CMD_QUEUE_LEN) return;
35
+
36
+	strncpy(cmd_queue[cmd_queue_pos], cmdline, sizeof(cmd_queue[0]));
37
+	cmd_queue_pos++;
38
+}
19 39
 
20
-int opt_utf8 = 0;
21
-int opt_verbosity = 0;
22
-int opt_log_calls = 0;
23
-int opt_dasm = 0;
40
+/* TODO: parse k, M, G etc */
41
+int parse_intval(char *s) {
42
+	return atoi(s);
43
+}
24 44
 
25 45
 int running = 1;
26 46
 
@@ -33,7 +53,12 @@ void sighandler(int signum) {
33 53
 void print_help(char *argv0) {
34 54
 	printf("Usage: %s [options] command [args]\n", argv0);
35 55
 	printf("Options:\n");
36
-	printf("\t-c \"<command>\"  Execute this command before main command. Example: -c mxdrv.x.\n");
56
+	printf("\t-c <command>      Execute this command before main command. Example: -c mxdrv.x.\n");
57
+	printf("\t-C <clock>        CPU clock. Default is %dMHz.\n", DEFAULT_CPU_CLOCK / 1000000);
58
+	printf("\t-M <size>         Specify size of RAM. Default is %dM.\n", DEFAULT_RAM_SIZE / 1024 / 1024);
59
+	printf("\t-R <rate>         Sample rate. Default is %d.\n", DEFAULT_SAMPLE_RATE);
60
+	printf("\t-b <size>         Audio buffer size. Default is %d.\n", DEFAULT_BUFFER_SIZE);
61
+	printf("\t-l <logfile.vgm>  VGM file logging.\n");
37 62
 	printf("\t-u                Convert output to utf-8.\n");
38 63
 	printf("\t-v                Increase verbosity by 1.\n");
39 64
 	printf("\t-t                Trace system calls (DOS, FE and IOCS).\n");
@@ -51,12 +76,31 @@ int parse_cmdline(int argc, char **argv) {
51 76
 			if(!strcmp(argv[i], "-c")) {
52 77
 				if(argc > i+1) {
53 78
 					i++;
54
-					v68_queue_command(argv[i]);
79
+					queue_cmd(argv[i]);
55 80
 				} else {
56 81
 					fprintf(stderr, "-c requires an argument\n");
57 82
 				}
83
+			} else if (!strcmp(argv[i], "-C")) {
84
+				i++;
85
+				opt_cpu_clock = parse_intval(argv[i]);
86
+			} else if (!strcmp(argv[i], "-M")) {
87
+				i++;
88
+				opt_ram_size = parse_intval(argv[i]);
89
+			} else if (!strcmp(argv[i], "-R")) {
90
+				i++;
91
+				opt_sample_rate = parse_intval(argv[i]);
92
+			} else if (!strcmp(argv[i], "-b")) {
93
+				i++;
94
+				opt_buffer_size = parse_intval(argv[i]);
95
+			} else if (!strcmp(argv[i], "-l")) {
96
+				i++;
97
+				opt_vgm_file = strdup(argv[i]);
58 98
 			} else if (!strcmp(argv[i], "-u")) {
59 99
 				opt_utf8 = 1;
100
+			} else if (!strcmp(argv[i], "-vvv")) {
101
+				opt_verbosity+=3;
102
+			} else if (!strcmp(argv[i], "-vv")) {
103
+				opt_verbosity+=2;
60 104
 			} else if (!strcmp(argv[i], "-v")) {
61 105
 				opt_verbosity++;
62 106
 			} else if (!strcmp(argv[i], "-t")) {
@@ -78,7 +122,7 @@ int parse_cmdline(int argc, char **argv) {
78 122
 		}
79 123
 	}
80 124
 	if(cmdbuf[0]) {
81
-		v68_queue_command(cmdbuf);
125
+		queue_cmd(cmdbuf);
82 126
 		return 0;
83 127
 	}
84 128
 
@@ -87,70 +131,93 @@ int parse_cmdline(int argc, char **argv) {
87 131
 }
88 132
 
89 133
 int main(int argc, char **argv, char **envp) {
90
-	int er = v68_init(V68_CLOCK, V68_RAM, SAMPLE_RATE);
91
-	if(er) {
92
-		fprintf(stderr, "Could not init VM! (%x)\n", er);
134
+	if(parse_cmdline(argc, argv)) {
135
+		fprintf(stderr, "Could not parse command line\n");
93 136
 		return -1;
94 137
 	}
95 138
 
96
-	if(parse_cmdline(argc, argv)) {
97
-		fprintf(stderr, "Could not parse command line\n");
139
+	int er = v68_init(opt_cpu_clock, opt_ram_size, opt_sample_rate);
140
+	if(er) {
141
+		fprintf(stderr, "Could not init VM! (%x)\n", er);
98 142
 		return -1;
99 143
 	}
100 144
 
101 145
 	v68.log_calls = opt_log_calls;
102 146
 	v68.log_dasm = opt_dasm;
103 147
 	v68.verbosity = opt_verbosity;
148
+	v68_boot();
149
+
150
+	for(int i = 0; i < cmd_queue_pos; i++) {
151
+		v68_queue_command(cmd_queue[i]);
152
+	}
104 153
 	v68_io_autodetect_drives();
105 154
 	v68_dump_drives();
106
-	struct vgm_logger l;
107
-	vgm_logger_begin(&l, "v68.vgm");
108
-	v68.logger = &l;
109
-
110 155
 	char *v68_path = getenv("V68_PATH");
111 156
 	v68_env_set("PATH", v68_path ? v68_path : getenv("PATH"));
112 157
 	for(char **e = envp; *e; e++) {
113 158
 		v68_env_append(*e);
114 159
 	}
115 160
 
116
-	// AO
117
-	ao_initialize();
161
+	v68_run();
118 162
 
119
-	int default_driver = ao_default_driver_id();
163
+	if(v68.sound_touched) {
164
+		printf("init sound\n");
165
+		// AO
166
+		ao_initialize();
120 167
 
121
-	ao_sample_format format;
122
-	memset(&format, 0, sizeof(format));
123
-	format.bits = 16;
124
-	format.channels = 2;
125
-	format.rate = SAMPLE_RATE;
126
-	format.byte_format = AO_FMT_LITTLE;
168
+		int default_driver = ao_default_driver_id();
127 169
 
128
-	ao_device *device = ao_open_live(default_driver, &format, NULL /* no options */);
129
-	if (device == NULL) {
130
-		fprintf(stderr, "Error opening device.\n");
131
-		return 1;
132
-	}
170
+		ao_sample_format format;
171
+		memset(&format, 0, sizeof(format));
172
+		format.bits = 16;
173
+		format.channels = 2;
174
+		format.rate = opt_sample_rate;
175
+		format.byte_format = AO_FMT_LITTLE;
176
+
177
+		ao_device *device = ao_open_live(default_driver, &format, NULL /* no options */);
178
+		if (device == NULL) {
179
+			fprintf(stderr, "Error opening device.\n");
180
+			return 1;
181
+		}
133 182
 
134
-	signal(SIGINT, sighandler);
183
+		signal(SIGINT, sighandler);
135 184
 
136
-	/* -- Play some stuff -- */
137
-	while(running) {
138
-		int16_t bufL[BUF_SIZE], bufR[BUF_SIZE];
139
-		int16_t buf[BUF_SIZE * 2];
140
-		v68_fill_buffer(bufL, bufR, BUF_SIZE);
141
-		for(int i = 0; i < BUF_SIZE; i++) {
142
-			buf[i * 2] = bufL[i];
143
-			buf[i * 2 + 1] = bufR[i];
185
+		if(opt_vgm_file && opt_vgm_file[0]) {
186
+			struct vgm_logger l;
187
+			vgm_logger_begin(&l, opt_vgm_file);
188
+			v68.logger = &l;
144 189
 		}
145
-		ao_play(device, (char *)buf, BUF_SIZE * format.channels * format.bits / 8);
190
+
191
+#define ALLOCBUF(b, s) \
192
+	int16_t *b = malloc(s); \
193
+	if(!b) { \
194
+		fprintf(stderr, "Could not allocate %lu bytes sound bufer\n", s); \
195
+		return 1; \
146 196
 	}
197
+		ALLOCBUF(bufL, opt_buffer_size * sizeof(*bufL));
198
+		ALLOCBUF(bufR, opt_buffer_size * sizeof(*bufR));
199
+		ALLOCBUF(tmpBufL, opt_buffer_size * sizeof(*tmpBufL));
200
+		ALLOCBUF(tmpBufR, opt_buffer_size * sizeof(*tmpBufR));
201
+		ALLOCBUF(buf, opt_buffer_size * 2 * sizeof(*buf));
202
+
203
+		/* -- Play some stuff -- */
204
+		while(running) {
205
+			v68_fill_buffer(opt_buffer_size, bufL, bufR, tmpBufL, tmpBufR);
206
+			for(int i = 0; i < opt_buffer_size; i++) {
207
+				buf[i * 2] = bufL[i];
208
+				buf[i * 2 + 1] = bufR[i];
209
+			}
210
+			ao_play(device, (char *)buf, opt_buffer_size * format.channels * format.bits / 8);
211
+		}
147 212
 
148
-	/* -- Close and shutdown -- */
149
-	ao_close(device);
213
+		/* -- Close and shutdown -- */
214
+		ao_close(device);
150 215
 
151
-	ao_shutdown();
216
+		ao_shutdown();
152 217
 
153
-	vgm_logger_end(&l);
218
+		if(v68.logger)
219
+			vgm_logger_end(v68.logger);
220
+	}
154 221
 
155 222
 	v68_shutdown();
156 223
 

+ 1
- 1
musashi/m68kconf.h View File

@@ -145,7 +145,7 @@ void v68_cpu_reset_instr_cb(void);
145 145
  * access a word or longword at an odd address.
146 146
  * NOTE: This is only emulated properly for 68000 mode.
147 147
  */
148
-#define M68K_EMULATE_ADDRESS_ERROR  OPT_OFF
148
+#define M68K_EMULATE_ADDRESS_ERROR  OPT_ON
149 149
 
150 150
 
151 151
 /* Turn ON to enable logging of illegal instruction calls.

+ 6
- 3
musashi/m68kcpu.c View File

@@ -669,11 +669,14 @@ int m68k_execute(int num_cycles, int dasm)
669 669
 
670 670
 				int d = m68k_disassemble(dasmbuf, REG_PC, CPU_TYPE);
671 671
 				printf("  D* %08X %08X %08X %08X %08X %08X %08X %08X\n",
672
-					REG_D[0], REG_D[1], REG_D[2], REG_D[3], REG_D[4], REG_D[5], REG_D[6], REG_D[7]);
672
+					REG_D[0], REG_D[1], REG_D[2], REG_D[3],
673
+					REG_D[4], REG_D[5], REG_D[6], REG_D[7]);
673 674
 				printf("  A* %08X %08X %08X %08X %08X %08X %08X %08X\n",
674
-					REG_A[0], REG_A[1], REG_A[2], REG_A[3], REG_A[4], REG_A[5], REG_A[6], REG_A[7]);
675
+					REG_A[0], REG_A[1], REG_A[2], REG_A[3],
676
+					REG_A[4], REG_A[5], REG_A[6], REG_A[7]);
675 677
 				printf("  PC=%08X  SR=%04X  cycles % 8d/%-8d\n",
676
-					REG_PC, m68k_get_reg(0, M68K_REG_SR), m68k_cycles_run(), m68k_cycles_remaining());
678
+					REG_PC, m68k_get_reg(0, M68K_REG_SR),
679
+					m68k_cycles_run(), m68k_cycles_remaining());
677 680
 				puts(dasmbuf);
678 681
 			}
679 682
 

+ 6
- 24
musashi/m68kcpu.h View File

@@ -130,12 +130,6 @@
130 130
 	}
131 131
 #endif /* ULONG_MAX == 0xffffffff */
132 132
 
133
-
134
-int v68_dos_call(uint16 instr);
135
-int v68_fe_call(uint16 instr);
136
-int v68_trap(int which);
137
-
138
-
139 133
 /* ======================================================================== */
140 134
 /* ============================ GENERAL DEFINES =========================== */
141 135
 /* ======================================================================== */
@@ -1743,11 +1737,9 @@ INLINE void m68ki_exception_trap(uint vector)
1743 1737
 /* Trap#n stacks a 0 frame but behaves like group2 otherwise */
1744 1738
 INLINE void m68ki_exception_trapN(uint vector)
1745 1739
 {
1746
-	if(v68_trap(vector - 32)) {
1747
-		uint sr = m68ki_init_exception();
1748
-		m68ki_stack_frame_0000(REG_PC, sr, vector);
1749
-		m68ki_jump_vector(vector);
1750
-	}
1740
+	uint sr = m68ki_init_exception();
1741
+	m68ki_stack_frame_0000(REG_PC, sr, vector);
1742
+	m68ki_jump_vector(vector);
1751 1743
 
1752 1744
 	/* Use up some clock cycles and undo the instruction's cycles */
1753 1745
 	USE_CYCLES(CYC_EXCEPTION[vector] - CYC_INSTRUCTION[REG_IR]);
@@ -1828,19 +1820,9 @@ INLINE void m68ki_exception_1111(void)
1828 1820
 					 m68ki_disassemble_quick(ADDRESS_68K(REG_PPC))));
1829 1821
 #endif
1830 1822
 
1831
-	int caught = 0;
1832
-	uint16 instr = m68k_read_memory_16(REG_PPC);
1833
-	if((instr & 0xff00) == 0xff00) {
1834
-		caught = !v68_dos_call(instr);
1835
-	} else if((instr & 0xff00) == 0xfe00) {
1836
-		caught = !v68_fe_call(instr);
1837
-	}
1838
-
1839
-	if(!caught) {
1840
-		sr = m68ki_init_exception();
1841
-		m68ki_stack_frame_0000(REG_PPC, sr, EXCEPTION_1111);
1842
-		m68ki_jump_vector(EXCEPTION_1111);
1843
-	}
1823
+	sr = m68ki_init_exception();
1824
+	m68ki_stack_frame_0000(REG_PPC, sr, EXCEPTION_1111);
1825
+	m68ki_jump_vector(EXCEPTION_1111);
1844 1826
 
1845 1827
 	/* Use up some clock cycles and undo the instruction's cycles */
1846 1828
 	USE_CYCLES(CYC_EXCEPTION[EXCEPTION_1111] - CYC_INSTRUCTION[REG_IR]);

+ 1
- 1
okim6258.c View File

@@ -154,7 +154,7 @@ void okim6258_update(struct okim6258 *chip, int16_t **outputs, int samples) {
154 154
 			}
155 155
 
156 156
 			nibble_shift ^= 4;
157
-			verbose2("okim6258_update samples=%d sample=%d\n", samples, sample);
157
+			// verbose2("okim6258_update samples=%d sample=%d\n", samples, sample);
158 158
 			*bufL++ = (chip->pan & 0x02) ? 0x00 : sample;
159 159
 			*bufR++ = (chip->pan & 0x01) ? 0x00 : sample;
160 160
 			samples--;

+ 2
- 0
tests/Makefile View File

@@ -16,6 +16,7 @@ all: \
16 16
 	oki1.x \
17 17
 	oki2.x \
18 18
 	oki3.x \
19
+	oki4.x \
19 20
 	ontime.x \
20 21
 	opm.x \
21 22
 	pcm8.x \
@@ -46,6 +47,7 @@ ontime.x: ontime.o
46 47
 oki1.x: oki1.o
47 48
 oki2.x: oki2.o
48 49
 oki3.x: oki3.o
50
+oki4.x: oki4.o tools.o
49 51
 opm.x: opm.o
50 52
 pcm8.x: pcm8.o
51 53
 pcm8en.x: pcm8en.o

+ 203
- 0
tests/filelist.s View File

@@ -0,0 +1,203 @@
1
+* DOS call files, sample of nfiles
2
+
3
+.include doscall.mac
4
+.include const.h
5
+
6
+.text
7
+.even
8
+
9
+ent:
10
+        lea.l mysp, sp * Initialization of sp
11
+        bsr chkarg     * Command line analysis
12
+        bsr do         * Main processing
13
+        DOS _EXIT      * Successful completion
14
+
15
+*
16
+*
17
+*
18
+
19
+do:
20
+        bsr chkname             * Preprocessing on file name
21
+
22
+        move.w #ARCHIVE, -(sp)  * Search for the first file
23
+        pea.l arg
24
+        pea.l filbuf
25
+        DOS _FILES
26
+        lea.l 10(sp), sp
27
+
28
+loop:   tst.l d0                * Did you find the file?
29
+        bmi done                * If it is not found, processing is completed
30
+
31
+        bsr setpath             * Reconfigure the obtained file name to the full path
32
+        bsr doit                * Process one file
33
+                                *
34
+        pea.l filbuf            * Search for the following file
35
+        DOS _NFILES
36
+        addq.l #4, sp
37
+
38
+        bra loop                * repeat
39
+
40
+done: rts
41
+
42
+                                * Process one file (just display the file name)
43
+
44
+doit:
45
+        pea.l arg               * It consists of setpath
46
+        DOS _PRINT              * File name of full path
47
+        addq.l #4, sp           * indicate
48
+
49
+        pea.l crlfms            * Begin on a new line
50
+        DOS _PRINT
51
+        addq.l #4, sp
52
+
53
+        rts
54
+
55
+* Preprocess the file name before executing files
56
+
57
+chkname:
58
+        pea.l nambuf            * Expand file name
59
+        pea.l arg
60
+        DOS _NAMECK
61
+        addq.l #8, sp
62
+
63
+        tst.l d0                * if d0 <0
64
+        bmi usage               * Invalid file name specification
65
+
66
+        beq nowild              * if d 0 = 0, no wildcard specification
67
+        cmpi.w #$00ff, d0
68
+        bne wild
69
+
70
+noname:
71
+        lea.l arg, a0
72
+        lea.l nambuf, a1
73
+        bsr strcpy
74
+        lea.l kome0, a1
75
+        bsr strcpy
76
+
77
+wild:
78
+
79
+chknam0: rts
80
+
81
+nowild:
82
+        move.w #SUBDIR, -(sp)
83
+        pea.l arg
84
+        pea.l filbuf
85
+        DOS _FILES
86
+        lea.l 10(sp), sp
87
+
88
+        tst.l d0
89
+        bmi chknam0
90
+
91
+        lea.l arg, a0
92
+        lea.l komekome, a1
93
+        bsr strcat
94
+
95
+        bra chkname
96
+
97
+setpath:
98
+        lea.l arg, a0
99
+        lea.l nambuf, a1
100
+        bsr strcpy
101
+        lea.l filbuf+30, a1
102
+        bsr strcpy
103
+        rts
104
+
105
+chkarg:
106
+        addq.l #1, a2
107
+        bsr skipsp
108
+*   tst.b (a2)
109
+*   beq usage
110
+
111
+        cmpi.b #'/', (a2)
112
+        beq usage
113
+        cmpi.b #'-', (a2)
114
+        beq usage
115
+
116
+        lea.l arg, a0
117
+        bsr getarg
118
+
119
+        bsr skipsp
120
+        tst.b (a2)
121
+        bne usage
122
+
123
+        rts
124
+
125
+getarg:
126
+        move.l a0, -(sp)
127
+gtarg0: tst.b (a2)
128
+        beq gtarg1
129
+        cmpi.b #SPACE, (a2)
130
+        beq gtarg1
131
+        cmpi.b #TAB, (a2)
132
+        beq gtarg1
133
+        cmpi.b #'-', (a2)
134
+        beq gtarg1
135
+        cmpi.b #'/', (a2)
136
+        beq gtarg1
137
+        move.b (a2)+, (a0)+
138
+        bra gtarg0
139
+gtarg1: clr.b (a0)
140
+        movea.l (sp)+, a0
141
+        rts
142
+
143
+skpsp0: addq.l #1, a2
144
+
145
+skipsp:
146
+        cmpi.b #SPACE, (a2)
147
+        beq sksp0
148
+        cmpi.b #TAB, (a2)
149
+        beq skpsp0
150
+        rts
151
+
152
+strcat:
153
+        tst.b (a0)+
154
+        bne strcat
155
+        subq.l #1, a0
156
+strcpy:
157
+        move.b (a1)+, (a0)+
158
+        bne strcpy
159
+        subq.l #1, a0
160
+
161
+        rts
162
+* Application of process operation
163
+usage:move. w #STDERR, -(sp)    * To standard error output
164
+pea.l usgmes                    * Help message
165
+DOS _FPUTS                      * Output
166
+addq. I #6, sp                  * Stack compensation
167
+
168
+move. w #1, -(sp)              * Have exit code 1
169
+DOS _EXIT2                      * Error Exit
170
+
171
+*
172
+*   Message data
173
+*
174
+.data
175
+.even
176
+
177
+usgmes:
178
+.dc.b 'Function: Displays the specified file name in full path',CR, LF
179
+.dc.b TAB,‘Wildcards can be used for file names', CR, LF
180
+.dc.b 'Usage: FILELIST [file name]'
181
+crlfms: .dc.b  CR, LF, 0
182
+komekome:
183
+.dc.b '\'
184
+kome0: .dc.b '*.*', 0
185
+*
186
+*   Work area
187
+*
188
+.bss
189
+.even
190
+
191
+arg: .ds.b 256    * Bow "number cutting buffer
192
+                                  * Put buffer used for files at even address
193
+filbuf: .ds.b 53  * File information storage buffer
194
+                                  * The buffer used by nameck may be an odd address
195
+nambuf:. ds. b 91 * Buffer for expanding name of file
196
+
197
+.stack
198
+.even
199
+
200
+mystack:
201
+.ds.l 256         * Stack area
202
+mysp:
203
+. end

+ 74
- 0
tests/oki4.s View File

@@ -0,0 +1,74 @@
1
+.include doscall.mac
2
+.include iocscall.mac
3
+.include const.h
4
+.include tools.h
5
+
6
+STACK_SIZE = 32*1024
7
+.text
8
+	move.l a1, a7
9
+	adda.l #STACK_SIZE, a7
10
+	lea (16,a0),a0
11
+	suba.l a0,a1
12
+	adda.l #STACK_SIZE,a1
13
+	move.l a1,-(sp)
14
+	move.l a0,-(sp)
15
+	DOS _SETBLOCK
16
+	addq.l #8,sp
17
+
18
+	pea dataSize
19
+	pea dataBlock
20
+	pea filename
21
+	bsr LoadFile
22
+	lea (12,sp),sp
23
+
24
+	pea dataSize2
25
+	pea dataBlock2
26
+	pea filename2
27
+	bsr LoadFile
28
+	lea (12,sp),sp
29
+
30
+	moveq.l	#$01,d1
31
+	IOCS _ADPCMMOD
32
+
33
+	moveq.l	#$00,d1
34
+	IOCS _ADPCMMOD
35
+
36
+	* Play sample!
37
+	move.w #$0403, d1
38
+	move.l (dataSize), d2
39
+	move.l (dataBlock), a1
40
+	IOCS _ADPCMOUT
41
+
42
+	move.w #$0403, d1
43
+	move.l (dataSize2), d2
44
+	move.l (dataBlock2), a1
45
+	IOCS _ADPCMOUT
46
+
47
+	move.w #$0100,d0
48
+	trap #2
49
+
50
+	pea.l (bye,pc)
51
+	DOS _PRINT
52
+	addq.l #4, sp
53
+
54
+	DOS _EXIT
55
+
56
+.data
57
+hello:
58
+.dc.b 'Hello', CR, LF, 0
59
+bye:
60
+.dc.b 'Done', CR, LF, 0
61
+filename:
62
+.dc.b 'piano-c4.adp', 0
63
+filename2:
64
+.dc.b 'piano-e4.adp', 0
65
+
66
+.bss
67
+dataBlock:
68
+.ds.l 1
69
+dataSize:
70
+.ds.l 1
71
+dataBlock2:
72
+.ds.l 1
73
+dataSize2:
74
+.ds.l 1

+ 0
- 0
tests/opmlib.s View File


+ 50
- 0
tests/pcm8_1.s View File

@@ -0,0 +1,50 @@
1
+.include doscall.mac
2
+.include iocscall.mac
3
+
4
+.cpu 68000
5
+
6
+.text
7
+	pea.l (helloStr,pc)
8
+	DOS _PRINT
9
+	addq.l #4, sp
10
+
11
+	movea.l ($0088),a0
12
+	move.l  (-$0008,a0),d0
13
+	cmp.l   #$50434d38,d0 ;'PCM8'
14
+	beq.s   FoundPCM8
15
+
16
+	pea.l (notFoundStr,pc)
17
+	DOS _PRINT
18
+	addq.l #4, sp
19
+
20
+	DOS _EXIT
21
+
22
+FoundPCM8:
23
+	pea.l (foundStr,pc)
24
+	DOS _PRINT
25
+	addq.l #4, sp
26
+
27
+	pea.l (stoppingStr,pc)
28
+	DOS _PRINT
29
+	addq.l #4, sp
30
+
31
+    move.l  #$0100,d0
32
+    trap    #2
33
+
34
+	pea.l (quittingStr,pc)
35
+	DOS _PRINT
36
+	addq.l #4, sp
37
+
38
+	DOS _EXIT
39
+
40
+.data
41
+helloStr:
42
+.dc.b 'PCM8 test 1', $0d, $0a, $00
43
+notFoundStr:
44
+.dc.b 'PCM8 Not found!', $0d, $0a, $00
45
+foundStr:
46
+.dc.b 'PCM8 Found!', $0d, $0a, $00
47
+stoppingStr:
48
+.dc.b 'Stopping PCM8 sounds', $0d, $0a, $00
49
+quittingStr:
50
+.dc.b 'Quitting', $0d, $0a, $00

+ 168
- 0
tests/pcm8_2.s View File

@@ -0,0 +1,168 @@
1
+.include doscall.mac
2
+.include iocscall.mac
3
+
4
+.cpu 68000
5
+
6
+.text
7
+Start:
8
+.include startup.s
9
+
10
+	; Become supervisor
11
+	clr.l	-(sp)
12
+	DOS _SUPER
13
+	addq.l #4, sp
14
+
15
+	; Greet everyone
16
+	pea.l (helloStr,pc)
17
+	DOS _PRINT
18
+	addq.l #4, sp
19
+
20
+	move #$0000,-(sp)
21
+	pea	(adpcmC4File)
22
+	DOS	_OPEN
23
+	addq.l	#6,sp
24
+
25
+	move.w d0, (adpcmC4Fd)
26
+
27
+	cmp.l #$00, d0
28
+	bge fileOpened
29
+
30
+	pea.l (couldNotOpenStr,pc)
31
+	DOS _PRINT
32
+	addq.l #4, sp
33
+
34
+	DOS _EXIT
35
+
36
+fileOpened:
37
+	pea.l (openedFileStr,pc)
38
+	DOS _PRINT
39
+	addq.l #4, sp
40
+
41
+	* Skip to a sample's pointer
42
+	move.w	#$02,-(sp)
43
+	move.l	#$00,-(sp)
44
+	move.w	(pianoC4Fd),-(sp)
45
+	DOS	_SEEK
46
+	addq.l	#8,sp
47
+
48
+	move.l (pianoC4Size), d0
49
+
50
+	move.w	#$00,-(sp)
51
+	move.l	#$00,-(sp)
52
+	move.w	(pianoC4Fd),-(sp)
53
+	DOS	_SEEK
54
+	addq.l	#8,sp
55
+
56
+	* Allocate memory for the sample
57
+	move.l (pianoC4Size), -(sp)
58
+	DOS	_MALLOC
59
+	addq.l	#4,sp
60
+
61
+	move.l d0, (pianoC4Block)
62
+
63
+	tst.l d0
64
+	bpl @f
65
+	pea.l (mallocErrStr,pc)
66
+	DOS _PRINT
67
+	addq.l #4, sp
68
+	DOS _EXIT
69
+@@:
70
+
71
+	* Read sample data
72
+	move.l (pianoC4Size), -(sp)
73
+	move.l (pianoC4Block), -(sp)
74
+	move.w (pianoC4Fd), -(sp)
75
+	DOS _READ
76
+	lea (10,sp),sp
77
+	* Check for error
78
+	tst.l d0
79
+	bpl @f
80
+	pea.l (readSampleErrStr,pc)
81
+	DOS _PRINT
82
+	addq.l #4, sp
83
+	DOS _EXIT
84
+@@:
85
+
86
+	* Close PDX file
87
+	move.w (pianoC4Fd), -(sp)
88
+	DOS	_CLOSE
89
+	addq.l	#4,sp
90
+
91
+	* Free sample mem block
92
+	move.l (pianoC4Block), -(sp)
93
+	DOS	_MFREE
94
+	addq.l	#4,sp
95
+
96
+	* Normal exit
97
+	DOS _EXIT
98
+
99
+WriteOPM:
100
+	ori.w	#$0300,sr
101
+@@:
102
+	tst.b	($00e90003)
103
+	bmi.s	@b
104
+	move.b	d1,($00e90001)
105
+	and.w	#$00ff,d1
106
+	move.b	d2,($00e90003)
107
+	andi.w	#$faff,sr
108
+	cmp.b	#$1b,d1
109
+	beq.s	@f
110
+	rts
111
+
112
+@@:
113
+	move.b	d2,($09da)
114
+	rts
115
+
116
+include itoh.s
117
+
118
+.data
119
+helloStr:
120
+.dc.b 'PCM8 test 1', $0d, $0a, $00
121
+setBlockErrStr:
122
+.dc.b 'Could not SETBLOCK', $0d, $0a, $00
123
+readErrStr:
124
+.dc.b 'Could not READ', $0d, $0a, $00
125
+readSampleErrStr:
126
+.dc.b 'Could not READ sample data', $0d, $0a, $00
127
+mallocErrStr:
128
+.dc.b 'Could not MALLOC', $0d, $0a, $00
129
+pianoC4File:
130
+.dc.b 'piano-c4.adp', $00
131
+pianoE4File:
132
+.dc.b 'piano-e4.adp', $00
133
+pianoG4File:
134
+.dc.b 'piano-g4.adp', $00
135
+
136
+couldNotOpenStr:
137
+.dc.b 'Could not open ADPCM file', $0d, $0a, $00
138
+openedFileStr:
139
+.dc.b 'Opened ADPCM file', $0d, $0a, $00
140
+crlf:
141
+.dc.b $0d, $0a, $00
142
+
143
+.bss
144
+.quad
145
+
146
+buf:
147
+.ds.b 32
148
+pianoC4fd:
149
+.ds.w 1
150
+pianoE4fd:
151
+.ds.w 1
152
+pianoG4fd:
153
+.ds.w 1
154
+pianoC4Block:
155
+.ds.l 1
156
+pianoE4Block:
157
+.ds.l 1
158
+pianoG4Block:
159
+.ds.l 1
160
+pianoC4Size:
161
+.ds.l 1
162
+pianoE4Size:
163
+.ds.l 1
164
+pianoG4Size:
165
+.ds.l 1
166
+WORK_SIZE:
167
+
168
+.end

+ 11549
- 0
tests/pcm8en.s
File diff suppressed because it is too large
View File


BIN
tests/piano-c4.adp View File


BIN
tests/piano-e4.adp View File


BIN
tests/piano-g4.adp View File


+ 0
- 3
tests/print.s View File

@@ -9,9 +9,6 @@
9 9
 
10 10
 	DOS _EXIT
11 11
 
12
-.bss
13
-.dc.l 0
14
-
15 12
 .data
16 13
 lHelloWorld:
17 14
 .dc.b 'Hello world!', $0d, $0a, $00

+ 26
- 0
tests/startup.s View File

@@ -0,0 +1,26 @@
1
+	; Setup stack and block size
2
+	; Include this file at entry point
3
+STACK_SIZE: .equ 32*1024
4
+	; a0 - Address of memory management pointer
5
+	; a1 - End address of program + 1
6
+
7
+	; Setup stack pointer
8
+	move.l a1, a7
9
+	add.l  STACK_SIZE, a7
10
+
11
+	; Reduce memory block
12
+	; So we can use malloc
13
+	lea     (16,a0),a0
14
+	suba.l		a0,a1
15
+	adda.l		#(WORK_SIZE-Start)+STACK_SIZE,a1
16
+	move.l		a1,-(sp)
17
+	move.l		a0,-(sp)
18
+	DOS		_SETBLOCK
19
+	addq.l		#8,sp
20
+	tst.l d0
21
+	bpl @f
22
+	pea.l (setBlockErrStr,pc)
23
+	DOS _PRINT
24
+	addq.l #4, sp
25
+	DOS _EXIT
26
+@@:

+ 2
- 0
tests/tools.h View File

@@ -0,0 +1,2 @@
1
+.global LoadFile
2
+.global WriteOPM

+ 107
- 0
tests/tools.s View File

@@ -0,0 +1,107 @@
1
+.include doscall.mac
2
+.include const.h
3
+
4
+.text:
5
+
6
+.global LoadFile
7
+LoadFile:
8
+	movem.l d1-d2/a1-a3,-(sp)
9
+	move.l (24,sp), a1
10
+	move.l (28,sp), a2
11
+	move.l (32,sp), a3
12
+
13
+	pea.l LoadFileLoadingStr
14
+	DOS _PRINT
15
+	addq.l #4, sp
16
+
17
+	move.l a1, -(sp)
18
+	DOS _PRINT
19
+	addq.l #4, sp
20
+
21
+	pea.l CRLF
22
+	DOS _PRINT
23
+	addq.l #4, sp
24
+
25
+	* Open the given file
26
+	move #$0000, -(sp)
27
+	move.l a1, -(sp)
28
+	DOS _OPEN
29
+	addq.l	#6,sp
30
+	* Return early if file desc is less than zero
31
+	tst.l d0
32
+	bmi LoadFileRet
33
+	* Store file descriptor
34
+	move.l d0, d1
35
+
36
+	* Seek to end
37
+	move.w #2, -(sp)
38
+	move.l #0, -(sp)
39
+	move.w d0, -(sp)
40
+	DOS	_SEEK
41
+	addq.l #8, sp
42
+	* Store file size
43
+	move.l d0, (a3)
44
+	* Rewind
45
+	move.w #0, -(sp)
46
+	move.l #0, -(sp)
47
+	move.w d1, -(sp)
48
+	DOS _SEEK
49
+	addq.l #8, sp
50
+
51
+	* Allocate mem
52
+	move.l (a3), -(sp)
53
+	DOS _MALLOC
54
+	addq.l #4, sp
55
+	* Check error
56
+	tst.l d0
57
+	bmi LoadFileClose
58
+	move.l d0, (a2)
59
+
60
+	* Read data into memory
61
+	move.l (a3), -(sp)
62
+	move.l (a2), -(sp)
63
+	move d1,-(sp)
64
+	DOS _READ
65
+	lea (10,sp),sp
66
+	* Check error
67
+	tst.l d0
68
+	bmi LoadFileFree
69
+
70
+	bra LoadFileClose
71
+
72
+LoadFileFree:
73
+	move.l (a2), -(sp)
74
+	DOS _MFREE
75
+	addq.l #4, sp
76
+LoadFileClose:
77
+	move d1, -(sp)
78
+	DOS _CLOSE
79
+	addq.l #2, sp
80
+LoadFileRet:
81
+	movem.l (sp)+,d1-d2/a1-a3
82
+	rts
83
+
84
+.global WriteOPM
85
+
86
+WriteOPM:
87
+	ori.w	#$0300,sr
88
+@@:
89
+	tst.b	($00e90003)
90
+	bmi.s	@b
91
+	move.b	d1,($00e90001)
92
+	and.w	#$00ff,d1
93
+	move.b	d2,($00e90003)
94
+	andi.w	#$faff,sr
95
+	cmp.b	#$1b,d1
96
+	beq.s	_storeB1
97
+	rts
98
+
99
+_storeB1:
100
+	move.b	d2,($09da)
101
+	rts
102
+
103
+.data
104
+LoadFileLoadingStr:
105
+	.dc.b 'Loading file ', 0
106
+CRLF:
107
+	.dc.b CR, LF, 0

+ 52
- 25
v68.c View File

@@ -11,9 +11,6 @@
11 11
 #include "v68iocscall.h"
12 12
 #include "musashi/m68kcpu.h"
13 13
 
14
-
15
-static void v68_reset_cb(void);
16
-
17 14
 struct v68 v68;
18 15
 
19 16
 int v68_init(int clock, int ram_size, int sample_rate) {
@@ -24,6 +21,7 @@ int v68_init(int clock, int ram_size, int sample_rate) {
24 21
 
25 22
 	v68.ram_size = ram_size;
26 23
 	v68.cpu_clock = clock;
24
+	v68.sound_touched = 0;
27 25
 	v68.sample_rate = sample_rate;
28 26
 	v68.samples_remainder = 0;
29 27
 
@@ -33,16 +31,18 @@ int v68_init(int clock, int ram_size, int sample_rate) {
33 31
 	m68k_init();
34 32
 	m68k_set_cpu_type(M68K_CPU_TYPE_68000);
35 33
 
34
+	v68_io_init();
35
+
36
+	return 0;
37
+}
38
+
39
+void v68_boot() {
40
+	verbose1("v68_boot\n");
36 41
 	v68_ipl_init();
37 42
 	v68_human_init();
38 43
 	v68_periph_init();
39
-
40
-	m68k_pulse_reset();
41
-
42
-	v68_io_init();
43 44
 	v68_iocs_init();
44
-
45
-	return 0;
45
+	m68k_pulse_reset();
46 46
 }
47 47
 
48 48
 void v68_cpu_reset_instr_cb(void) {
@@ -57,12 +57,35 @@ int v68_shutdown() {
57 57
 }
58 58
 
59 59
 extern int m68ki_initial_cycles;
60
-int v68_fill_buffer(int16_t *bufL, int16_t *bufR, int samples) {
61
-	printf("v68_fill_buffer samples=%d\n", samples);
60
+void v68_run() {
61
+	verbose1("v68_run cpu_clock=%d sound_touched=%d running=%d\n", v68.cpu_clock, v68.sound_touched, v68.running);
62
+	int remaining_tstates = v68.cpu_clock;
63
+
64
+	v68.running = 1;
65
+
66
+	while(!v68.sound_touched) {
67
+		while(remaining_tstates > 0 && v68.running) {
68
+			int next_int = v68_periph_next_int(remaining_tstates);
69
+			verbose2("v68_run  executing next_int=%d remaining_tstates=%d\n", next_int, remaining_tstates);
70
+			v68.cpu_ended_timeslice = 0;
71
+			v68.prev_sound_cycles = 0;
72
+			int cycles = m68k_execute(next_int, v68.log_dasm);
73
+			int executed_cycles = v68.cpu_ended_timeslice ? next_int - m68ki_initial_cycles : cycles;
74
+			verbose2("v68_run  ended_timeslice=%d executed_cycles=%d next_int=%d remaining_tstates = %d\n", v68.cpu_ended_timeslice, executed_cycles, next_int, remaining_tstates);
75
+			v68.cpu_ended_timeslice = 0;
76
+			if(v68.sound_touched) return;
77
+		}
78
+	}
79
+}
80
+
81
+int v68_fill_buffer(int samples, int16_t *bufL, int16_t *bufR, int16_t *tmpBufL, int16_t *tmpBufR) {
82
+	verbose1("v68_fill_buffer samples=%d\n", samples);
62 83
 	v68.prev_sound_cycles = 0;
63 84
 	v68.buf_remaining = samples;
64 85
 	v68.bufL = bufL;
65 86
 	v68.bufR = bufR;
87
+	v68.tmpBufL = tmpBufL;
88
+	v68.tmpBufR = tmpBufR;
66 89
 	memset(bufL, 0, samples * sizeof(*bufL));
67 90
 	memset(bufR, 0, samples * sizeof(*bufR));
68 91
 
@@ -117,8 +140,8 @@ unsigned int m68k_read_memory_8(unsigned int addr) {
117 140
 	}
118 141
 
119 142
 	if(addr >= v68.ram_size) {
120
-		verbose2("READ8 ERROR 0x%08x\n", addr);
121
-		return 0;
143
+		fprintf(stderr, "READ8 ERROR 0x%08x\n", addr);
144
+		exit(1);
122 145
 	}
123 146
 
124 147
 	uint8_t r = v68.ram[addr];
@@ -146,8 +169,8 @@ unsigned int  m68k_read_memory_16(unsigned int addr) {
146 169
 	}
147 170
 
148 171
 	if(addr >= v68.ram_size - 1) {
149
-		verbose2("READ16 ERROR 0x%08x\n", addr);
150
-		return 0;
172
+		fprintf(stderr, "READ16 ERROR 0x%08x\n", addr);
173
+		exit(1);
151 174
 	}
152 175
 
153 176
 	uint16_t r = (v68.ram[addr] << 8) | v68.ram[addr + 1];
@@ -175,11 +198,15 @@ unsigned int  m68k_read_memory_32(unsigned int addr) {
175 198
 	}
176 199
 
177 200
 	if(addr > v68.ram_size) {
178
-		verbose2("READ32 ERROR 0x%08x\n", addr);
179
-		return 0;
201
+		fprintf(stderr, "READ32 ERROR 0x%08x\n", addr);
202
+		exit(1);
180 203
 	}
181 204
 
182
-	uint32_t r = (v68.ram[addr] << 24) | (v68.ram[addr+1] << 16) | (v68.ram[addr+2] << 8) | v68.ram[addr+3];
205
+	uint32_t r =
206
+		(v68.ram[addr] << 24) |
207
+		(v68.ram[addr+1] << 16) |
208
+		(v68.ram[addr+2] << 8) |
209
+		v68.ram[addr+3];
183 210
 	verbose3("READ32 RAM 0x%08x = 0x%08x\n", addr, r);
184 211
 	return r;
185 212
 }
@@ -192,22 +219,22 @@ void m68k_write_memory_8(unsigned int addr, unsigned int data) {
192 219
 	}
193 220
 	verbose3("WRITE8 RAM 0x%08x = 0x%02x\n", addr, data);
194 221
 	if(addr > v68.ram_size) {
195
-		verbose2("Could not write RAM at 0x%08x = 0x%02x\n", addr, data);
196
-		return;
222
+		fprintf(stderr, "Could not write RAM at 0x%08x = 0x%02x\n", addr, data);
223
+		exit(1);
197 224
 	}
198 225
 	v68.ram[addr] = data;
199 226
 }
200 227
 
201 228
 void m68k_write_memory_16(unsigned int addr, unsigned int data) {
229
+	verbose3("WRITE16 0x%08x = 0x%04x\n", addr, data);
202 230
 	if(addr >= 0x00e80000 && addr < 0x00eb0000) {
203 231
 		verbose3("WRITE16 PERIPH 0x%08x = 0x%04x\n", addr, data);
204 232
 		v68_write_periph_16(addr, data);
205 233
 		return;
206 234
 	}
207
-	verbose3("WRITE16 RAM 0x%08x = 0x%04x\n", addr, data);
208 235
 	if(addr > v68.ram_size) {
209
-		verbose2("Could not write RAM at 0x%08x = 0x%04x\n", addr, data);
210
-		return;
236
+		fprintf(stderr, "Could not write RAM at 0x%08x = 0x%04x\n", addr, data);
237
+		exit(1);
211 238
 	}
212 239
 	v68.ram[addr++] = data >> 8;
213 240
 	v68.ram[addr] = data;
@@ -221,8 +248,8 @@ void m68k_write_memory_32(unsigned int addr, unsigned int data) {
221 248
 	}
222 249
 	verbose3("WRITE32 RAM 0x%08x = 0x%08x\n", addr, data);
223 250
 	if(addr > v68.ram_size) {
224
-		verbose2("Could not write RAM at 0x%08x = 0x%08x\n", addr, data);
225
-		return;
251
+		fprintf(stderr, "Could not write RAM at 0x%08x = 0x%08x\n", addr, data);
252
+		exit(1);
226 253
 	}
227 254
 
228 255
 	v68.ram[addr++] = data >> 24;

+ 21
- 16
v68.h View File

@@ -37,30 +37,26 @@
37 37
 #define logcall(fmt...) { if(v68.log_calls) printf(fmt); }
38 38
 
39 39
 struct v68 {
40
+	int log_dasm, verbosity;
41
+
42
+	/* VM */
40 43
 	uint8_t *ram;
41 44
 	size_t ram_size;
42
-
43
-	/* Memory allocation */
44
-	int heap_start, heap_top;
45
-
46
-#define V68_CMD_QUEUE_LEN 8
47
-	char cmd_queue[V68_CMD_QUEUE_LEN][1024];
48
-	int cmd_queue_pos;
49
-	int running;
50 45
 	int reset_pulsed;
51 46
 
52 47
 	/* MFP */
53 48
 	int int_vec;
54 49
 
50
+	/* CPU timing */
51
+	int cpu_clock, cpu_cycle_remainder, cpu_ended_timeslice;
52
+
55 53
 	/* Sound Timing */
56
-	int16_t *bufL, *bufR;
54
+	int sound_touched;
55
+	int16_t *bufL, *bufR, *tmpBufL, *tmpBufR;
57 56
 	int sample_rate;
58 57
 	int samples_remainder, buf_remaining;
59 58
 	int prev_sound_cycles, remaining_tstates;
60 59
 
61
-	/* CPU timing */
62
-	int cpu_clock, cpu_cycle_remainder, cpu_ended_timeslice;
63
-
64 60
 	/* Peripheral timing */
65 61
 	int periph_timers_altered, in_periph_timing, periph_cycles;
66 62
 
@@ -85,16 +81,25 @@ struct v68 {
85 81
 	/* VGM logging */
86 82
 	struct vgm_logger *logger;
87 83
 
88
-	uint32_t cur_prog_addr; // address of currently running program
84
+	/* OS */
85
+	/* Memory allocation */
86
+	int heap_start, heap_top;
89 87
 
90
-	int log_calls, log_dasm, verbosity;
88
+#define V68_CMD_QUEUE_LEN 8
89
+	int running;
90
+	char cmd_queue[V68_CMD_QUEUE_LEN][1024];
91
+	int cmd_queue_pos;
92
+	uint32_t cur_prog_addr; // address of currently running program
93
+	int log_calls;
91 94
 };
92 95
 
93 96
 extern struct v68 v68;
94 97
 
95 98
 int v68_init(int clock, int ram_size, int sample_rate);
96
-int v68_shutdown();
97
-int v68_fill_buffer(int16_t *bufL, int16_t *bufR, int samples);
99
+void v68_boot(void);
100
+void v68_run(void);
101
+int v68_fill_buffer(int samples, int16_t *bufL, int16_t *bufR, int16_t *tmpBufL, int16_t *tmpBufR);
102
+int v68_shutdown(void);
98 103
 
99 104
 /* Traps */
100 105
 int v68_trap(int which);

+ 3
- 0
v68doscall.h View File

@@ -0,0 +1,3 @@
1
+#pragma once
2
+
3
+int v68_dos_call(uint16_t instr);

+ 5
- 0
v68fecall.h View File

@@ -0,0 +1,5 @@
1
+#pragma once
2
+
3
+
4
+
5
+int v68_fe_call(uint16_t instr);

+ 10
- 6
v68human.c View File

@@ -238,11 +238,11 @@ int v68_run_command(char *cmd) {
238 238
 		verbose2("Entry point: 0x%08x + 0x%08x = 0x%08x cmd_queue_pos=%d\n", entry_point, reloc_adj, pc, v68.cmd_queue_pos);
239 239
 		m68k_set_reg(M68K_REG_PC, pc);
240 240
 		m68k_set_reg(M68K_REG_A4, pc); // program start addr
241
+		// REG_USP = STACK_TOP + STACK_SIZE;
242
+		// REG_ISP = STACK_TOP + STACK_SIZE;
243
+		// REG_MSP = STACK_TOP + STACK_SIZE;
244
+//		m68k_set_reg(M68K_REG_SR, m68k_get_reg(0, M68K_REG_SR) & ~0x2000);
241 245
 		m68k_set_reg(M68K_REG_A7, STACK_TOP + STACK_SIZE);
242