.n64
.create "\RelN64\cart.N64",0x80000000

	.org 0x80000000 	;Cartridge Start

	.db 0x80,0x37,0x12,0x40 	;0x0000 - PI_BSB x4
	.dw 0x0000000F 				;0x0004 - Clock Rate
	.dw ProgramStart 			;0x0008 - Program Start address
	.dw 0x00001444 				;0x000C - Release Offset
	.dw 0,0						;0x0010 - CRC1+2
	.dw 0,0 					;0x0018 - Unknown
	;    12345678901234567890
	.db "WWW.LEARNASM.NET    "	;0x0020 - Cartridge Title

	.dw 0						;0x0034 - Unknown
	.dw 0	 					;0x0038 - Manufacturer ID
	.db 0,0						;0x003C - Cartridge ID
	.db 'J',0					;0x003E - Country Code (E=Usa / J=Japan / P=Europe)

;0x80000040-0x80001000 Bootstrap (4032 bytes)
	.incbin "\ResN64\Boot.bin"		;Generic header ripped from actual game

ProgramStart:
 
.definelabel UserRam,0xA0010000
  
	li a0,0xA4400000
  
	li t0,2					;16 bit
	sw t0,0(a0)			;0xA4400000	VI_STATUS_REG	VI status/control (Read/Write)
  
	li t0,0xA0100000 		;VRAM Base
	sw t0,4(a0)			;0xA4400004	VI_ORIGIN_REG	VI origin (Read/Write)
  
	li t0,320   			;Width
	sw t0,8(a0)			;0xA4400008	VI_WIDTH_REG	VI width (Read/Write)
  
	li t0,0x200    			;Vertical Interrupt (Half line)
	sw t0,12(a0)		;0xA440000C	VI_INTR_REG	VI vertical intr (Read/Write)
  
	li t0,0        			;Current half line
	sw t0,16(a0)		;0xA4400010	VI_CURRENT_REG	VI current vertical line (Read/Write)

	li t0,0x03E52239   		;0xCVBW		C=Color burst start V=Vert sync width(halflines) 
										;B=ColorBurst in pixels W=Hync Width in pixels
	sw t0,20(a0)		;0xA4400014	VI_BURST_REG	VI video timing (Read/Write)
  
	li t0,0x20D    			;Halflines per field
	sw t0,24(a0)		;0xA4400018	VI_V_SYNC_REG	VI vertical sync (Read/Write)
  
	li t0,0x00000C15  		;0x--LLTTT	T=Total linr duration in .25 pixel / L=leap pattern
	sw t0,28(a0)		;0xA440001C	VI_H_SYNC_REG	VI horizontal sync (Read/Write)
  
	li t0,0x0C150C15  		;0x-HHH-hhh	h+H are identical to hsync period
	sw t0,32(a0)		;0xA4400020	VI_LEAP_REG	VI horizontal sync leap (Read/Write)
  
	li t0,0x006C02EC    	;0x-SSS-EEE S=Start of Horiz active screen / E=end of screen
	sw t0,36(a0)		;0xA4400024	VI_H_START_REG	VI horizontal video (Read/Write)

	li t0,0x002501FF     	;0x-SSS-EEE S=Start of Vert active screen / E=end of screen
	sw t0,40(a0)		;0xA4400028	VI_V_START_REG	VI vertical video (Read/Write)
  
	li t0,0x000E0204 		;0x-SSS-EEE S=Start of Vert color burst / E=end of burst
	sw t0,44(a0)		;0xA440002C	VI_V_BURST_REG	VI vertical burst (Read/Write)
  
	li t0,0x00000200		;0xOOOOSSSS O=Horiz subpixel offset / =Scaleup factor
	sw t0,48(a0)		;0xA4400030	VI_X_SCALE_REG	VI x-scale (Read/Write)
  
	li t0,0x00000400		;0xOOOOSSSS O=Vert subpixel offset / =Scaleup factor
	sw t0,52(a0)		;0xA4400034	VI_Y_SCALE_REG	VI y-scale (Read/Write)
  