mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-01 18:41:13 -07:00
bitshift divison
This commit is contained in:
@@ -8,6 +8,10 @@ load_uimm equ lui ; dst_reg, immediate value (unsigned)
|
||||
load_word equ lw ; dst_reg, offset(src_reg0) (offset is immediate value)
|
||||
; Store
|
||||
store_word equ sw ; src_reg, dst_address
|
||||
; Shift
|
||||
shift_ll equ sll ;
|
||||
shift_rl equ srl ;
|
||||
shift_ra equ sra ;
|
||||
; Addition
|
||||
add_s equ add ; dst_reg, reg_a, reg_b (signed)
|
||||
add_u equ add ; dst_reg, reg_a, reg_b (unsigned)
|
||||
|
||||
@@ -66,7 +66,8 @@ gp_ModeSetting_DipArea equ 0xE1 << gcmd_offset | 0x1 << gp_ModeSetting_DrawA
|
||||
|
||||
; GP0(E3h) - Set Drawing Area top left (X1,Y1)
|
||||
; GP0(E4h) - Set Drawing Area bottom right (X2,Y2)
|
||||
; Sets the drawing area corners. The Render commands GP0(20h..7Fh) are automatically clipping any pixels that are outside of this region.
|
||||
; Sets the drawing area corners. The Render commands GP0(20h..7Fh)
|
||||
; are automatically clipping any pixels that are outside of this region.
|
||||
; 0 - 9 X-coordinate (0..1023)
|
||||
; 10 - 18 Y-coordinate (0..511) ; \ on v0 GPU (max 1 MB VRAM)
|
||||
; 19 - 23 Not used (zero) ; /
|
||||
|
||||
@@ -92,15 +92,15 @@ main:
|
||||
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_2, 100 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 0 * gp_vec2($sp)
|
||||
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 rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 2 * gp_vec2($sp)
|
||||
load_imm rarg_2, 100 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 0 * gp_vec2($sp)
|
||||
load_imm rarg_2, 20 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 1 * gp_vec2($sp)
|
||||
load_imm rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 2 * gp_vec2($sp)
|
||||
jump_nlink gp_draw_tri_flat :: nop
|
||||
; Bonus traingle
|
||||
load_imm rarg_1, Color_PS_CadmiumRed
|
||||
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_2, 0 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 1 * gp_vec2($sp)
|
||||
load_imm rarg_2, -100 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: sw rarg_2, 2 * gp_vec2($sp)
|
||||
load_imm rarg_2, 50 * -1 + Display_HalfHeight << gp_b16_Y | -100 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 0 * gp_vec2($sp)
|
||||
load_imm rarg_2, 0 * -1 + Display_HalfHeight << gp_b16_Y | 20 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 1 * gp_vec2($sp)
|
||||
load_imm rarg_2, -100 * -1 + Display_HalfHeight << gp_b16_Y | 30 + Display_HalfWidth << gp_b16_X :: store_word rarg_2, 2 * gp_vec2($sp)
|
||||
jump_nlink gp_draw_tri_flat :: nop
|
||||
stack_release gp_draw_tri_flat__sp_size
|
||||
; Gourand shaded triangle
|
||||
@@ -114,16 +114,13 @@ main:
|
||||
|
||||
; Copy image contents to vram
|
||||
gcmd_push gp0, rtmp_1, gp_Blit_CPU_VM
|
||||
gcmd_push gp0, rtmp_1, (Image_SizeY / 2) * -1 + Display_HalfHeight << gp_b16_Y | -(Image_SizeX / 2) + Display_HalfWidth << gp_b16_X
|
||||
gcmd_push gp0, rtmp_1, 0 << gp_b16_Y | Display_Width << gp_b16_X
|
||||
gcmd_push gp0, rtmp_1, Image_SizeY << gp_b16_Y | Image_SizeX << gp_b16_X
|
||||
; DMA commands
|
||||
@id equ rtmp_2
|
||||
@img_cursor equ rtmp_3
|
||||
@divisor equ rtmp_3
|
||||
load_imm @id, Image_ByteSize
|
||||
load_imm @divisor, word
|
||||
div @id, @divisor
|
||||
mov_from_high @id
|
||||
shift_rl @id, @id, (word / 2)
|
||||
load_addr @img_cursor, Image
|
||||
loop_dma:
|
||||
load_word rtmp_1, (@img_cursor) :: nop :: store_word rtmp_1, gp0 ; @img_curor -> gp_dma_cpu_vm(word)
|
||||
|
||||
Reference in New Issue
Block a user