hcs
Member
Registered: Oct 2001
Location: NJ, USA
Posts: 81 |
I can't really help you on the C side, but here's some basic startup code in ASM:
code:
org $80000400 ; entry point (the (standard) header loads your
; code to $80000400)
; always do this first thing, otherwise the N64
; crashes in approx. 5 seconds
li t1,8
lui t0,$bfc0
sw t1,$07fc(t0)
; Initialize video (I won't go into what all the
; values mean, but it initializes the screen to
; 320x240 16 bit color mode)
lui t0,$a440 ; VI register base
li t1, $103002
sw t1,0(t0)
la t1,0xa0200000 ; the frame buffer address
sw t1,4(t0)
li t1,320
sw t1,8(t0)
li t1,$2
sw t1,12(t0)
li t1,$0
sw t1,16(t0)
li t1,$3e52239
sw t1,20(t0)
li t1,$0000020d
sw t1,24(t0)
li t1,$00000c15
sw t1,28(t0)
li t1,$0c150c15
sw t1,32(t0)
li t1,$006c02ec
sw t1,36(t0)
li t1,$002501ff
sw t1,40(t0)
li t1,$000e0204
sw t1,44(t0)
li t1,$200
sw t1,48(t0)
li t1,$400
sw t1,52(t0)
; clear the screen
la t0,0xa0200000
li t1,320*240*2-2
li t2,0 ; black
loopclear:
sh t2,0(t0)
add t0,2
bnez t1,loopclear
sub t1,2
deadend
j deadend
nop
I assume whatever assembler you're using has support for the bnez and la pseudo opcodes.
After assembling this program, merge it together with a header (as you stated above). You should then extend the file to 2 megabytes in size, preferably by just appending zeroes (if you are using a v64jr the elim send utilty will automatically send zeroes for you so you can skip this step). Then, in order to actually use it on the N64 you must recalculate the checksums, using for example a program on Dextrose called chksum64. elim will also perform this step for you if you use it.
If you're only intending to run it in emulators you can probably get away with only attaching the header. And on the subject of emulators Nemu is a very good choice for low-level N64 work, its debugging features are excellent.
If you want some of my demo sources, like a text engine that runs on the RSP, just ask!
__________________
-hcs
Last edited by hcs on 05-13-2003 at 06:04 AM
Report this post to a moderator | IP: Logged
|