gs2loaduc.s
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*---------------------------------------------------------------------
Copyright (C) 1997, Nintendo.
File gs2loaduc.s
Coded by Yoshitaka Yasumoto. Aug 7, 1997.
Modified by
Comments
$Id: gs2loaduc.s,v 1.1.1.1 2002/05/02 03:29:12 blythe Exp $
---------------------------------------------------------------------*/
#------------------------------------------------------------------
# マイクロコードの SWITCH 処理 12 insts. 計 27insts.
# SMARTINP で +2 insts.
# DMA2BUF/DMANOWAIT で +3 insts.
# DMANOWAIT2 で +6 insts.
# RDPHALF のコピー で +1 inst.
#
# +--------------+------------+------------+------------+
# |G_RDPHALF_1 | |
# +--------------+------------+------------+------------+
# | Pointer for ucode (Data section) |
# +--------------+------------+------------+------------+
# |G_SWITCH_UCODE| | (ucode_data size)-1 |
# +--------------+------------+------------+------------+
# | Pointer for ucode (Text section) |
# +--------------+------------+------------+------------+
#
Assign(dlcount, 28) /* F3DEX と共通 */
case_G_SWITCH_UCODE:
#
# F3DEX 系コマンドと位置を合わせるために RSP_STATEP_RDPHALF_1L の
# 値を 0x010c 番地にコピーする
# また SMARTINP と処理を共通にするために dlcount に 0 を代入する
#
addi dlcount, zero, 0
lw $19, RSP_STATEP_RDPHALF_1L(zero) # Data Section
# DMANOWAIT2
addi $6, outp, -(RSP_OUTPUT_OFFSET+1)
bgezal $6, OutputCloseFlush
# nop
sw $19, 0x010c(zero)
# DMANOWAIT
jal DMAwait
lw $6, RSP_STATEP_FIFO_OUTP(zero)
mtc0 $6, CMD_END
# これ以降 全マイクロコード 共通のコードとなる
addi $19, gfx1, 0 # Text Section
sw gfx1, (RSP_TASK_OFFSET+OS_TASK_OFF_UCODE)(zero)
# Ucode の保存
# SMARTINP
add inp, inp, dinp
sub inp, inp, dlcount
sw inp, (RSP_TASK_OFFSET+OS_TASK_OFF_DATA)(zero)
addi $20, zero, TASKBASELO # Load into IMEM
jal DMAread
addi $18, zero, (0x1000-0x0080-26*4-1) # gloaduc
# RSP_STATEP_RDPHALF データは 0x010c 番地になければならない
# lw $19, RSP_STATEP_RDPHALF(zero) # Data Section
lw $19, 0x010c(zero) # Data Section
addi $20, zero, 0x0000 # Load into DMEM
jal DMAread
andi $18, gfx0, 0xffff # Get length
addi $1, zero, RSP_TASK_OFFSET # Set taskp
addi return, zero, TASKBASELO # Wiat DMA & Jump to ucode top
EndAssign(dlcount, 28) /* F3DEX と共通 */
#--------------------------------
# DMA 待ち 4 insts.
#
.name tmp, $11
DMAwait: mfc0 tmp, DMA_BUSY
DMAwait1: bne tmp, zero, DMAwait1
mfc0 tmp, DMA_BUSY
ReturnToR31: jr return
.unname tmp
#--------------------------------
# DMA 処理 11 insts.
#
.name mem_addr, $20
.name dram_addr, $19
.name dma_len, $18
.name iswrite, $17
.name tmp, $11
DMAread: add iswrite, zero, zero
DMAproc: mfc0 tmp, DMA_FULL
bne tmp, zero, DMAproc
nop
# set DMA registers:
mtc0 mem_addr, DMA_CACHE
# handle writes:
bgtz iswrite, DMAWrite
mtc0 dram_addr, DMA_DRAM
jr return
mtc0 dma_len, DMA_READ_LENGTH
DMAWrite:
jr return
mtc0 dma_len, DMA_WRITE_LENGTH
.unname mem_addr
.unname dram_addr
.unname dma_len
.unname iswrite
.unname tmp