<NME> SHADOWS.MIP
<BEF> 	opt at-,w-,c+,m-

	SECTION	ASM
	INCLUDE	SPEC_PSX/GLOBAL.INC
	XDEF S_DrawGouraudBar, OptimiseOTagR, calcval, DelLine, DelBox, S_PrintNiceShadow
	XREF db

S_PrintNiceShadow:
	jr ra
	nop
	
calcval:
	mult    at, t5
	mflo    at
	nop
	nop
	div     v0, t6
	jr      ra
	mflo    at

S_DrawGouraudBar:
	addiu   sp, -0x20
	addiu   t8, 0x14
	
DelBox:
	lui     at, 0x300
	or      t7, at
	sw      t7, 0(t8)
	sw      a2, 4(t8)
	sw      a0, 8(t8)
	sw      a1, 0xC(t8)
	move    t7, t8
	jr      ra
	addiu   t8, 0x10

S_DrawGouraudBar:
	addiu   sp, -0x20
	sw      s0, 0x20-0x10(sp)
	sw      s1, 0x20-0xC(sp)
	sw      ra, 0x20-0x8(sp)
	lw      t9, db+0x4-GP_ADDR(gp)
	lw      t8, db+0x8-GP_ADDR(gp)
	lw      at, db+0x10-GP_ADDR(gp)
	lw      t7, 0(t9)
	sltu    at, t8, at
	beqz    at, loc_87160
	move    t6, a2
	move    s0, a0
	move    s1, a1
	move    t3, a3
	beqz    t3, loc_870AC
	addiu   t3, -1
	subu    t5, t6, t3
	lw      t2, 0x20+0x10(sp)
	li      t4, 5
	andi    a0, s0, 0xFFFF
	sll     at, s1, 16
	addu    a1, a0, t3
	or      a0, at
	or      a1, at

	loc_87038:
	lbu     at, 0(t2)
	lbu     v0, 0xF(t2)
	jal     calcval
	move    t0, at
	move    a3, at
	lbu     at, 5(t2)
	lbu     v0, 0x14(t2)
	jal     calcval
	move    t1, at
	move    a2, at
	lbu     at, 0xA(t2)
	lbu     v0, 0x19(t2)
	jal     calcval
	move    v1, at
	sll     at, 16
	or      a3, at, a3
	sll     a2, 8
	or      a3, a2
	sll     t1, 8
	or      a2, t1, t0
	sll     v1, 16
	jal     DelLine
	or      a2, v1
	addiu   t2, 1
	lui     at, 1
	addu    a0, at
	addiu   t4, -1
	bnez    t4, loc_87038
	addu    a1, at

	loc_870AC:
	addiu   s0, -2
	addiu   s1, -2
	sll     t2, s1, 16
	addu    t3, s0, t6
	addiu   t3, 4
	addiu   t4, s1, 8
	sll     t4, 16
	or      a0, s0, t2
	or      a1, t3, t2
	li      a2, 0x828250
	lui     a3, 0xA0
	jal     DelLine
	or      a3, 0xA0A0
	or      a0, t3, t4
	jal     DelLine
	or      a1, s0, t4
	or      a1, t3, t2
	jal     DelLine
	or      a0, t3, t4
	or      a1, s0, t4
	jal     DelLine
	or      a0, s0, t2
	lui     at, 1
	addu    t2, at
	subu    t4, at
	addiu   s0, -1
	or      a0, s0, t2
	or      a1, s0, t4
	li      a2, 0x414128
	lui     a3, 0x50
	jal     DelLine
	li      a3, 0x505050
	addiu   t3, 1
	or      a1, t3, t2
	jal     DelLine
	or      a0, t3, t4
	addiu   s0, 2
	or      a0, s0, t2
	addiu   v0, t6, 3
	lui     a1, 7
	or      a1, v0, a1
	jal     DelBox
	lui     a2, 0x6000

	loc_87160:
	lw      ra, 0x20-0x8(sp)
	lw      s1, 0x20-0xC(sp)
	lw      s0, 0x20-0x10(sp)
	addiu   sp, 0x20
	sw      t7, 0(t9)
	jr      ra
	sw      t8, db+0x8-GP_ADDR(gp)
	
OptimiseOTagR:
	slti    at, a1, 8
	bnez    at, locret_86D14
	move    at, zero
	sll     a1, 2
	addiu   a1, -4
	addu    a1, a0
	addiu   v1, a0, 4
	lw      v0, 0(a1)

	loc_86CE4:
	addiu   a1, -4
	bne     v0, a1, loc_86D0C
	addiu   a3, a1, 4
	beq     a1, a0, locret_86D14

	loc_86CF4:
	lw      v0, 0(a1)
	beq     a1, v1, loc_86D08
	addiu   a1, -4
	beq     v0, a1, loc_86CF4
	addiu   at, 1

	loc_86D08:
	sw      v0, 0(a3)

	loc_86D0C:
	bne     a1, a0, loc_86CE4
	lw      v0, 0(a1)

	locret_86D14:
	jr      ra
	move    v0, at
<MSG> Add DelLine

<DFF> @@ -17,6 +17,20 @@ calcval:
 	div     v0, t6
 	jr      ra
 	mflo    at
+	
+DelLine:
+	lui     at, 0x5000
+	or      a2, at
+	sw      a2, 4(t8)
+	sw      a0, 8(t8)
+	sw      a3, 0xC(t8)
+	sw      a1, 0x10(t8)
+	lui     at, 0x400
+	or      t7, at
+	sw      t7, 0(t8)
+	move    t7, t8
+	jr      ra
+	addiu   t8, 0x14
 
 S_DrawGouraudBar:
 	addiu   sp, -0x20

{'commit': 'diff --git a/SPEC_PSX/SHADOWS.MIP b/SPEC_PSX/SHADOWS.MIP\nindex 7a41c739..548cfb59 100644\n--- a/SPEC_PSX/SHADOWS.MIP\n+++ b/SPEC_PSX/SHADOWS.MIP\n@@ -17,6 +17,20 @@ calcval:\n \tdiv     v0, t6\n \tjr      ra\n \tmflo    at\n+\t\n+DelLine:\n+\tlui     at, 0x5000\n+\tor      a2, at\n+\tsw      a2, 4(t8)\n+\tsw      a0, 8(t8)\n+\tsw      a3, 0xC(t8)\n+\tsw      a1, 0x10(t8)\n+\tlui     at, 0x400\n+\tor      t7, at\n+\tsw      t7, 0(t8)\n+\tmove    t7, t8\n+\tjr      ra\n+\taddiu   t8, 0x14\n \n S_DrawGouraudBar:\n \taddiu   sp, -0x20\n', 'commit_subject': 'Add DelLine', 'repo_name': 'TOMB5/TOMB5', 'committer': {'name': 'Gh0stBlade', 'email': '19ffcc48b5297ad4998e7ea4f40eaa34eefb03dd@users.noreply.github.com', 'time_sec': '1541289397', 'tz_offset': '0', 'date': {'seconds': '1541289397'}}, 'commit_tree': '1a6407ecc638ae5a16ae93ce8312b60d4801be9a', 'commit_message': 'Add DelLine\n', 'language_name': 'C', 'license': 'mit', 'hunks': '@@ -17,6 +17,20 @@ calcval:\n \tdiv     v0, t6\n \tjr      ra\n \tmflo    at\n+\t\n+DelLine:\n+\tlui     at, 0x5000\n+\tor      a2, at\n+\tsw      a2, 4(t8)\n+\tsw      a0, 8(t8)\n+\tsw      a3, 0xC(t8)\n+\tsw      a1, 0x10(t8)\n+\tlui     at, 0x400\n+\tor      t7, at\n+\tsw      t7, 0(t8)\n+\tmove    t7, t8\n+\tjr      ra\n+\taddiu   t8, 0x14\n \n S_DrawGouraudBar:\n \taddiu   sp, -0x20\n', 'addition_count': 14, 'deletion_count': 0, 'src_file': 'a/SPEC_PSX/SHADOWS.MIP', 'tgt_file': 'b/SPEC_PSX/SHADOWS.MIP', 'file_extension': '.MIP', 'before_file': '\topt at-,w-,c+,m-\n\n\tSECTION\tASM\n\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n\tXDEF S_DrawGouraudBar, OptimiseOTagR, calcval, DelLine, DelBox, S_PrintNiceShadow\n\tXREF db\n\nS_PrintNiceShadow:\n\tjr ra\n\tnop\n\t\ncalcval:\n\tmult    at, t5\n\tmflo    at\n\tnop\n\tnop\n\tdiv     v0, t6\n\tjr      ra\n\tmflo    at\n\nS_DrawGouraudBar:\n\taddiu   sp, -0x20\n\taddiu   t8, 0x14\n\t\nDelBox:\n\tlui     at, 0x300\n\tor      t7, at\n\tsw      t7, 0(t8)\n\tsw      a2, 4(t8)\n\tsw      a0, 8(t8)\n\tsw      a1, 0xC(t8)\n\tmove    t7, t8\n\tjr      ra\n\taddiu   t8, 0x10\n\nS_DrawGouraudBar:\n\taddiu   sp, -0x20\n\tsw      s0, 0x20-0x10(sp)\n\tsw      s1, 0x20-0xC(sp)\n\tsw      ra, 0x20-0x8(sp)\n\tlw      t9, db+0x4-GP_ADDR(gp)\n\tlw      t8, db+0x8-GP_ADDR(gp)\n\tlw      at, db+0x10-GP_ADDR(gp)\n\tlw      t7, 0(t9)\n\tsltu    at, t8, at\n\tbeqz    at, loc_87160\n\tmove    t6, a2\n\tmove    s0, a0\n\tmove    s1, a1\n\tmove    t3, a3\n\tbeqz    t3, loc_870AC\n\taddiu   t3, -1\n\tsubu    t5, t6, t3\n\tlw      t2, 0x20+0x10(sp)\n\tli      t4, 5\n\tandi    a0, s0, 0xFFFF\n\tsll     at, s1, 16\n\taddu    a1, a0, t3\n\tor      a0, at\n\tor      a1, at\n\n\tloc_87038:\n\tlbu     at, 0(t2)\n\tlbu     v0, 0xF(t2)\n\tjal     calcval\n\tmove    t0, at\n\tmove    a3, at\n\tlbu     at, 5(t2)\n\tlbu     v0, 0x14(t2)\n\tjal     calcval\n\tmove    t1, at\n\tmove    a2, at\n\tlbu     at, 0xA(t2)\n\tlbu     v0, 0x19(t2)\n\tjal     calcval\n\tmove    v1, at\n\tsll     at, 16\n\tor      a3, at, a3\n\tsll     a2, 8\n\tor      a3, a2\n\tsll     t1, 8\n\tor      a2, t1, t0\n\tsll     v1, 16\n\tjal     DelLine\n\tor      a2, v1\n\taddiu   t2, 1\n\tlui     at, 1\n\taddu    a0, at\n\taddiu   t4, -1\n\tbnez    t4, loc_87038\n\taddu    a1, at\n\n\tloc_870AC:\n\taddiu   s0, -2\n\taddiu   s1, -2\n\tsll     t2, s1, 16\n\taddu    t3, s0, t6\n\taddiu   t3, 4\n\taddiu   t4, s1, 8\n\tsll     t4, 16\n\tor      a0, s0, t2\n\tor      a1, t3, t2\n\tli      a2, 0x828250\n\tlui     a3, 0xA0\n\tjal     DelLine\n\tor      a3, 0xA0A0\n\tor      a0, t3, t4\n\tjal     DelLine\n\tor      a1, s0, t4\n\tor      a1, t3, t2\n\tjal     DelLine\n\tor      a0, t3, t4\n\tor      a1, s0, t4\n\tjal     DelLine\n\tor      a0, s0, t2\n\tlui     at, 1\n\taddu    t2, at\n\tsubu    t4, at\n\taddiu   s0, -1\n\tor      a0, s0, t2\n\tor      a1, s0, t4\n\tli      a2, 0x414128\n\tlui     a3, 0x50\n\tjal     DelLine\n\tli      a3, 0x505050\n\taddiu   t3, 1\n\tor      a1, t3, t2\n\tjal     DelLine\n\tor      a0, t3, t4\n\taddiu   s0, 2\n\tor      a0, s0, t2\n\taddiu   v0, t6, 3\n\tlui     a1, 7\n\tor      a1, v0, a1\n\tjal     DelBox\n\tlui     a2, 0x6000\n\n\tloc_87160:\n\tlw      ra, 0x20-0x8(sp)\n\tlw      s1, 0x20-0xC(sp)\n\tlw      s0, 0x20-0x10(sp)\n\taddiu   sp, 0x20\n\tsw      t7, 0(t9)\n\tjr      ra\n\tsw      t8, db+0x8-GP_ADDR(gp)\n\t\nOptimiseOTagR:\n\tslti    at, a1, 8\n\tbnez    at, locret_86D14\n\tmove    at, zero\n\tsll     a1, 2\n\taddiu   a1, -4\n\taddu    a1, a0\n\taddiu   v1, a0, 4\n\tlw      v0, 0(a1)\n\n\tloc_86CE4:\n\taddiu   a1, -4\n\tbne     v0, a1, loc_86D0C\n\taddiu   a3, a1, 4\n\tbeq     a1, a0, locret_86D14\n\n\tloc_86CF4:\n\tlw      v0, 0(a1)\n\tbeq     a1, v1, loc_86D08\n\taddiu   a1, -4\n\tbeq     v0, a1, loc_86CF4\n\taddiu   at, 1\n\n\tloc_86D08:\n\tsw      v0, 0(a3)\n\n\tloc_86D0C:\n\tbne     a1, a0, loc_86CE4\n\tlw      v0, 0(a1)\n\n\tlocret_86D14:\n\tjr      ra\n\tmove    v0, at', 'message': 'Add DelLine\n', 'author_name': 'Gh0stBlade', 'lang': 'MIP'}