mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-01 18:41:13 -07:00
stack parameters gp routine!
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
; Load
|
; Load
|
||||||
load_imm equ li ; dst_reg, immeidate value (signed)
|
load_imm equ li ; dst_reg, immeidate value (signed)
|
||||||
load_uimm equ lui ; dst_reg, immediate value (unsigned)
|
load_uimm equ lui ; dst_reg, immediate value (unsigned)
|
||||||
|
load_word equ lw ; dst_reg, offset(src_reg0) (offset is immediate value)
|
||||||
; Store
|
; Store
|
||||||
store_word equ sw ; src_reg, dst_address
|
store_word equ sw ; src_reg, dst_address
|
||||||
; Addition
|
; Addition
|
||||||
@@ -26,6 +27,8 @@ jump_reg equ jr ; address: register
|
|||||||
jump_nreg equ jrl ; subroutine: register
|
jump_nreg equ jrl ; subroutine: register
|
||||||
|
|
||||||
; Registers
|
; Registers
|
||||||
|
; Stack
|
||||||
|
rstack_ptr equ $sp ; I have this but won't really use the alias..
|
||||||
; Temporaries, may be changed by subroutines
|
; Temporaries, may be changed by subroutines
|
||||||
rtmp_0 equ $t0
|
rtmp_0 equ $t0
|
||||||
rtmp_1 equ $t1
|
rtmp_1 equ $t1
|
||||||
@@ -51,3 +54,15 @@ rret_0 equ $v0
|
|||||||
rret_1 equ $v1
|
rret_1 equ $v1
|
||||||
; Subroutine return address when doing a sub
|
; Subroutine return address when doing a sub
|
||||||
rret_addr equ $ra
|
rret_addr equ $ra
|
||||||
|
|
||||||
|
; Data Widths
|
||||||
|
byte equ 1
|
||||||
|
word equ 4
|
||||||
|
|
||||||
|
.macro stack_alloc, amount
|
||||||
|
add_ui $sp, - amount
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
.macro stack_release, amount
|
||||||
|
add_ui $sp, amount
|
||||||
|
.endmacro
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ gp_b10_Y equ 10
|
|||||||
gp_b16_X equ 0
|
gp_b16_X equ 0
|
||||||
gp_b16_Y equ 16
|
gp_b16_Y equ 16
|
||||||
|
|
||||||
|
gp_vec2 equ word
|
||||||
|
|
||||||
.macro gp_push_pak, port, reg_scratch, packet
|
.macro gp_push_pak, port, reg_scratch, packet
|
||||||
load_imm reg_scratch, packet
|
load_imm reg_scratch, packet
|
||||||
store_word reg_scratch, port
|
store_word reg_scratch, port
|
||||||
@@ -131,23 +133,23 @@ gp_b16_Y equ 16
|
|||||||
.org 0x80010000 + 2000
|
.org 0x80010000 + 2000
|
||||||
|
|
||||||
.func gp_draw_tri_flat ;(
|
.func gp_draw_tri_flat ;(
|
||||||
@@io_offset equ rarg_0
|
gp_draw_tri_flat__sp_size equ (3 * gp_vec2)
|
||||||
@@color equ rarg_1
|
@@io_offset equ rarg_0 ; io_offset: word
|
||||||
@@vert_1 equ rarg_2
|
@@color equ rarg_1 ; color: word
|
||||||
@@vert_2 equ rarg_3
|
@@verts equ $sp ; verts: [3]gp_vec2
|
||||||
@@vert_3 equ rstatic_0
|
|
||||||
;)
|
;)
|
||||||
|
@@vert_id equ rtmp_1
|
||||||
@@cmd equ rtmp_2
|
@@cmd equ rtmp_2
|
||||||
load_imm @@cmd, gp_Polygon
|
load_imm @@cmd, gp_Polygon
|
||||||
or @@cmd, @@cmd, @@color
|
or @@cmd, @@cmd, @@color
|
||||||
store_word @@cmd, gpio_port0(@@io_offset)
|
store_word @@cmd, gpio_port0(@@io_offset)
|
||||||
store_word @@vert_1, gpio_port0(@@io_offset)
|
load_word @@vert_id, 0 * gp_vec2(@@verts) :: nop :: store_word @@vert_id, gpio_port0(@@io_offset)
|
||||||
store_word @@vert_2, gpio_port0(@@io_offset)
|
load_word @@vert_id, 1 * gp_vec2(@@verts) :: nop :: store_word @@vert_id, gpio_port0(@@io_offset)
|
||||||
store_word @@vert_3, gpio_port0(@@io_offset)
|
load_word @@vert_id, 2 * gp_vec2(@@verts) :: nop :: store_word @@vert_id, gpio_port0(@@io_offset)
|
||||||
jump_reg rret_addr :: nop
|
jump_reg rret_addr :: nop
|
||||||
.endfunc
|
.endfunc
|
||||||
|
|
||||||
.func gp_draw_tri_grouand ;(
|
.func gp_draw_tri_gouraud ;(
|
||||||
@@io_offset equ rarg_0
|
@@io_offset equ rarg_0
|
||||||
@@color equ rarg_1
|
@@color equ rarg_1
|
||||||
@@color_2 equ rstatic_1
|
@@color_2 equ rstatic_1
|
||||||
|
|||||||
@@ -46,18 +46,20 @@ main:
|
|||||||
gcmd_push gp0, rtmp_1, -30 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X
|
gcmd_push gp0, rtmp_1, -30 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X
|
||||||
gcmd_push gp0, rtmp_1, -50 * -1 + Display_HalfHeight << gp_b16_Y | 55 + Display_HalfWidth << gp_b16_X
|
gcmd_push gp0, rtmp_1, -50 * -1 + Display_HalfHeight << gp_b16_Y | 55 + Display_HalfWidth << gp_b16_X
|
||||||
; Draw a flat-shaded triangle
|
; Draw a flat-shaded triangle
|
||||||
move rarg_0, reg_io_offset ; arg 1 for gp_draw_tri_flat
|
stack_alloc gp_draw_tri_flat__sp_size ; (used for following call)
|
||||||
|
move rarg_0, reg_io_offset ; (used for following call)
|
||||||
load_imm rarg_1, Color_PS_GoldenPoppy
|
load_imm rarg_1, Color_PS_GoldenPoppy
|
||||||
load_imm rarg_2, 100 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, 100 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 0 * gp_vec2($sp)
|
||||||
load_imm rarg_3, 20 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, 20 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 1 * gp_vec2($sp)
|
||||||
load_imm rstatic_0, 50 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 2 * gp_vec2($sp)
|
||||||
jump_nlink gp_draw_tri_flat :: nop
|
jump_nlink gp_draw_tri_flat :: nop
|
||||||
; Bonus traingle
|
; Bonus traingle
|
||||||
load_imm rarg_1, Color_PS_CadmiumRed
|
load_imm rarg_1, Color_PS_CadmiumRed
|
||||||
load_imm rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 0 * gp_vec2($sp)
|
||||||
load_imm rarg_3, 0 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, 0 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 1 * gp_vec2($sp)
|
||||||
load_imm rstatic_0, -100 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, -100 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 2 * gp_vec2($sp)
|
||||||
jump_nlink gp_draw_tri_flat :: nop
|
jump_nlink gp_draw_tri_flat :: nop
|
||||||
|
stack_release gp_draw_tri_flat__sp_size
|
||||||
; Gourand shaded triangle
|
; Gourand shaded triangle
|
||||||
load_imm rarg_1, Color_PS_PersianGreen
|
load_imm rarg_1, Color_PS_PersianGreen
|
||||||
load_imm rstatic_1, Color_PS_GoldenPoppy
|
load_imm rstatic_1, Color_PS_GoldenPoppy
|
||||||
@@ -65,7 +67,7 @@ main:
|
|||||||
load_imm rarg_2, -35 * -1 + Display_HalfHeight << gp_b16_Y | 145 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_2, -35 * -1 + Display_HalfHeight << gp_b16_Y | 145 + Display_HalfWidth << gp_b16_X
|
||||||
load_imm rarg_3, 0 * -1 + Display_HalfHeight << gp_b16_Y | 50 + Display_HalfWidth << gp_b16_X
|
load_imm rarg_3, 0 * -1 + Display_HalfHeight << gp_b16_Y | 50 + Display_HalfWidth << gp_b16_X
|
||||||
load_imm rstatic_0, 40 * -1 + Display_HalfHeight << gp_b16_Y | 60 + Display_HalfWidth << gp_b16_X
|
load_imm rstatic_0, 40 * -1 + Display_HalfHeight << gp_b16_Y | 60 + Display_HalfWidth << gp_b16_X
|
||||||
jump_nlink gp_draw_tri_grouand :: nop
|
jump_nlink gp_draw_tri_gouraud :: nop
|
||||||
|
|
||||||
idle:
|
idle:
|
||||||
jump idle :: nop
|
jump idle :: nop
|
||||||
|
|||||||
Reference in New Issue
Block a user