initial commit
[psx_test1] / src / startup.S
1 #include <regdef.h>
2
3         .equ REG_BASE, 0x1f80
4         .equ REG_GP0, 0x1810
5         .equ REG_GP1, 0x1814
6
7         .set noreorder
8         .section .startup
9
10         .extern main
11
12         .globl _start
13 _start:
14         lui a0, REG_BASE
15
16         # setup screen mode
17         li t0, 0
18         sw t0, REG_GP1(a0)      # GP1 0: reset
19
20         li t0, 0x03000000       # GP1 3: display enable
21         sw t0, REG_GP1(a0)
22         li t0, 0x08000009       # GP1 8: display mode (320x240 15bpp PAL)
23         sw t0, REG_GP1(a0)
24         li t0, 0x06c60260       # GP1 6: horiz. display range (608-3168)
25         sw t0, REG_GP1(a0)
26         li t0, 0x07049c1f       # GP1 7: vert. display range (31-295)
27         sw t0, REG_GP1(a0)
28
29         li t0, 0xe1000600       # GP0 e1: draw mode (draw allowed & dither enable)
30         sw t0, REG_GP0(a0)
31         li t0, 0xe3000000       # draw area top left (0, 0)
32         sw t0, REG_GP0(a0)
33         li t0, 0xe4041d3f       # draw area bottom right (319,263)
34         sw t0, REG_GP0(a0)
35         li t0, 0xe5000000       # draw offset (0, 0)
36         sw t0, REG_GP0(a0)
37
38         # clear screen
39         li t0, 0x02302010       # cmd 2: fill area (BBGGRR)
40         sw t0, REG_GP0(a0)
41         li t0, 0
42         sw t0, REG_GP0(a0)      # ... top left 0,0 (YYYYXXXX)
43         li t0, 0x00ef013f       # ... size 319x239 (HHHHWWWW)
44         sw t0, REG_GP0(a0)
45
46         # draw gouraud triangle
47         li t0, 0x30ff0000
48         sw t0, REG_GP0(a0)
49         li t0, 160 | (16 << 16)
50         sw t0, REG_GP0(a0)
51
52         li t0, 0x0000ff00
53         sw t0, REG_GP0(a0)
54         li t0, 32 | (180 << 16)
55         sw t0, REG_GP0(a0)
56
57         li t0, 0x000000ff
58         sw t0, REG_GP0(a0)
59         li t0, 280 | (220 << 16)
60         sw t0, REG_GP0(a0)
61
62         #jal main
63         nop
64
65 0:      b 0b
66         nop
67
68 # vi:ts=8 sts=8 sw=8 ft=mips: