mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-01 18:41:13 -07:00
hello_images
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
; Instructions
|
||||
; Load
|
||||
load_addr equ la ;
|
||||
load_imm equ li ; dst_reg, immeidate value (signed)
|
||||
load_uimm equ lui ; dst_reg, immediate value (unsigned)
|
||||
load_word equ lw ; dst_reg, offset(src_reg0) (offset is immediate value)
|
||||
@@ -15,11 +16,19 @@ add_ui equ addiu ; dst_reg, src_reg, immediate value (unsigned)
|
||||
; Subtraction
|
||||
sub_s equ sub ;
|
||||
sub_u equ subu ;
|
||||
; Multiplication
|
||||
|
||||
; Division
|
||||
div_s equ div ;
|
||||
div_u equ divu ;
|
||||
mov_from_high equ mfhi ;
|
||||
mov_from_low equ mflo ;
|
||||
; Branch
|
||||
branch_equal equ beq ; reg, value(reg, immediate), dst_label
|
||||
branch_gt_equal equ bge ; reg, value(reg, immediate), dst_label
|
||||
branch_gt equ bgt ; reg, value(reg, immediate), dst_label
|
||||
branch_lt equ blt ; reg, value(reg, immediate), dst_label
|
||||
branch_ne_zero equ bnez ;
|
||||
branch_equal equ beq ; reg, value(reg, immediate), dst_label
|
||||
branch_gt_equal equ bge ; reg, value(reg, immediate), dst_label
|
||||
branch_gt equ bgt ; reg, value(reg, immediate), dst_label
|
||||
branch_lt equ blt ; reg, value(reg, immediate), dst_label
|
||||
; Jump
|
||||
jump equ j ; address: immediate
|
||||
jump_nlink equ jal ; subroutine: immeidate
|
||||
|
||||
+37
-15
@@ -11,22 +11,19 @@ gcmd_offset equ 24
|
||||
|
||||
gp_Reset equ 0x0 << gcmd_offset
|
||||
|
||||
; GP1(03h) - Display Enable
|
||||
; On: 0x0
|
||||
; Off: 0x1
|
||||
gp_DisplayEnabled equ (0x03 << gcmd_offset) | 0x0
|
||||
gp_DisplayDisabled equ (0x03 << gcmd_offset) | 0x1
|
||||
gp_DisplayEnabled equ 0x03 << gcmd_offset | 0x0
|
||||
gp_DisplayDisabled equ 0x03 << gcmd_offset | 0x1
|
||||
|
||||
; GP1(08h) - Display mode
|
||||
; 0-1 Horizontal Resolution 1 (0=256, 1=320, 2=512, 3=640) ;GPUSTAT.17-18
|
||||
; 2 Vertical Resolution (0=240, 1=480, when Bit5=1) ;GPUSTAT.19
|
||||
; 3 Video Mode (0=NTSC/60Hz, 1=PAL/50Hz) ;GPUSTAT.20
|
||||
; 4 Display Area Color Depth (0=15bit, 1=24bit) ;GPUSTAT.21
|
||||
; 5 Vertical Interlace (0=Off, 1=On) ;GPUSTAT.22
|
||||
; 6 Horizontal Resolution 2 (0=256/320/512/640, 1=368) ;GPUSTAT.16
|
||||
; 7 Flip screen horizontally (0=Off, 1=On, v1 only) ;GPUSTAT.14
|
||||
; 8-23 Not used (zero)
|
||||
@DisplayMode equ 0x08
|
||||
gp_DisplayMode_320x240_15bit_NTSC equ @DisplayMode << gcmd_offset | 0x0 << 7 | 0x0 << 6 | 0x0 << 5 | 0x0 << 4 | 0x0 << 3 | 0x0 << 2 | 0x1
|
||||
; GP1(04h) - DMA Direction / Data Request
|
||||
; 0-1 DMA Direction (0=Off, 1=FIFO, 2=CPUtoGP0, 3=GPUREADtoCPU) ;GPUSTAT.29-30
|
||||
; 2-23 Not used (zero)
|
||||
gp_DMA_FIFO equ 1
|
||||
gp_DMA_CPU_to_GPU equ 2
|
||||
gp_DMA_GPU_to_CPU equ 3
|
||||
gp_DMA_Request equ 0x04 << gcmd_offset
|
||||
|
||||
; GP1(06h) - Horizontal Display range (on Screen)
|
||||
; X2 = X1 + pixels * cycles_per_pix
|
||||
@@ -40,6 +37,18 @@ gp_HorizontalDisplayRange_3168_608 equ 0x06 << gcmd_offset | 0xC60 << 12 | 0x260
|
||||
; 20 - 23 Not used (zero)
|
||||
gp_VerticalDisplayRange_264_24 equ 0x07 << gcmd_offset | 264 << 10 | 24
|
||||
|
||||
; GP1(08h) - Display mode
|
||||
; 0-1 Horizontal Resolution 1 (0=256, 1=320, 2=512, 3=640) ;GPUSTAT.17-18
|
||||
; 2 Vertical Resolution (0=240, 1=480, when Bit5=1) ;GPUSTAT.19
|
||||
; 3 Video Mode (0=NTSC/60Hz, 1=PAL/50Hz) ;GPUSTAT.20
|
||||
; 4 Display Area Color Depth (0=15bit, 1=24bit) ;GPUSTAT.21
|
||||
; 5 Vertical Interlace (0=Off, 1=On) ;GPUSTAT.22
|
||||
; 6 Horizontal Resolution 2 (0=256/320/512/640, 1=368) ;GPUSTAT.16
|
||||
; 7 Flip screen horizontally (0=Off, 1=On, v1 only) ;GPUSTAT.14
|
||||
; 8-23 Not used (zero)
|
||||
@DisplayMode equ 0x08
|
||||
gp_DisplayMode_320x240_15bit_NTSC equ @DisplayMode << gcmd_offset | 0x0 << 7 | 0x0 << 6 | 0x0 << 5 | 0x0 << 4 | 0x0 << 3 | 0x0 << 2 | 0x1
|
||||
|
||||
;GP0(E1h) - Draw Mode setting (aka "Texpage")
|
||||
; 0 - 3 Texture page X Base (N * 64) (ie. in 64-halfword steps) ; GPUSTAT.0-3
|
||||
; 4 Texture page Y Base 1 (N * 256) (ie. 0, 256, 512 or 768) ; GPUSTAT.4
|
||||
@@ -90,6 +99,18 @@ gp_SetOffset equ 0xE5 << gcmd_offset
|
||||
; Fill is NOT affected by the Mask settings (acts as if Mask.Bit0,1 are both zero).
|
||||
gp_RectFillVM equ 0x02 << gcmd_offset
|
||||
|
||||
; GP0(A0h) - Copy Rectangle (CPU to VRAM)
|
||||
; Transfers data from CPU to frame buffer.
|
||||
; If the number of halfwords to be sent is odd, an extra halfword should be sent,
|
||||
; as packets consist of 32bits words. The transfer is affected by Mask setting.
|
||||
; 1st Command (Cc000000h)
|
||||
; 2nd Destination Coord (YyyyXxxxh) ;Xpos counted in halfwords
|
||||
; 3rd Width+Height (YsizXsizh) ;Xsiz counted in halfwords
|
||||
; ... Data (...) <--- usually transferred via DMA
|
||||
gp_Blit_VM_VM equ 0x80 << gcmd_offset
|
||||
gp_Blit_CPU_VM equ 0xA0 << gcmd_offset
|
||||
gp_Blit_VM_CPU equ 0xC0 << gcmd_offset
|
||||
|
||||
; GPU Render Polygon Commands
|
||||
|
||||
; When the upper 3 bits of the first GP0 command are set to 1 (001),
|
||||
@@ -119,7 +140,8 @@ gp_b10_Y equ 10
|
||||
gp_b16_X equ 0
|
||||
gp_b16_Y equ 16
|
||||
|
||||
gp_vec2 equ word
|
||||
gp_pixel equ (2 * byte)
|
||||
gp_vec2 equ word
|
||||
|
||||
.macro gp_push_pak, port, reg_scratch, packet
|
||||
load_imm reg_scratch, packet
|
||||
@@ -130,7 +152,7 @@ gp_vec2 equ word
|
||||
store_word reg_scratch, port
|
||||
.endmacro
|
||||
|
||||
.org 0x80010000 + 2000
|
||||
.org 0x80010000 + 3000
|
||||
|
||||
.func gp_draw_tri_flat ;(
|
||||
gp_draw_tri_flat__sp_size equ (3 * gp_vec2)
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
.psx
|
||||
.create "./build/hello_image.bin", 0x80010000
|
||||
|
||||
.include "./code/graphics_system/dsl.s"
|
||||
.include "./code/graphics_system/gp.s"
|
||||
|
||||
Color_RedFF equ 0x0000FF
|
||||
Color_22 equ 0x222222
|
||||
Color_PS_CadmiumRed equ 0x2400DF
|
||||
Color_PS_CelticBlue equ 0x723F00
|
||||
Color_PS_GoldenPoppy equ 0x00C3F3
|
||||
Color_PS_PersianGreen equ 0x9FAC00
|
||||
|
||||
Display_Width equ 319
|
||||
Display_Height equ 239
|
||||
Display_HalfWidth equ 319 / 2
|
||||
Display_HalfHeight equ 239 / 2
|
||||
|
||||
|
||||
.org 0x80010000 + 4000
|
||||
|
||||
Image_SizeX equ 32
|
||||
Image_SizeY equ 32
|
||||
Image_ByteSize equ Image_SizeX * Image_SizeY * gp_pixel
|
||||
|
||||
Image:
|
||||
; 32 * 32 * 2 = 2048 bytes
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60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F,0x0AFF,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60
|
||||
.hword 0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x7500,0x7500,0x7500,0x7500,0x7500,0x7500,0x0AFF,0x0AFF,0x0AF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0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0AFF,0x0AFF,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
.hword 0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60,0x0A60
|
||||
|
||||
; Entry Point of Code
|
||||
.org 0x80010000
|
||||
main:
|
||||
reg_io_offset equ rtmp_0
|
||||
load_uimm rtmp_0, IO_BASE_ADDR
|
||||
|
||||
gp0 equ gpio_port0(reg_io_offset)
|
||||
gp1 equ gpio_port1(reg_io_offset)
|
||||
|
||||
; Setup Display Control
|
||||
gcmd_push gp1, rtmp_1, gp_Reset
|
||||
gcmd_push gp1, rtmp_1, gp_DisplayEnabled
|
||||
gcmd_push gp1, rtmp_1, gp_DisplayMode_320x240_15bit_NTSC
|
||||
gcmd_push gp1, rtmp_1, gp_HorizontalDisplayRange_3168_608
|
||||
gcmd_push gp1, rtmp_1, gp_VerticalDisplayRange_264_24
|
||||
gcmd_push gp0, rtmp_1, gp_ModeSetting_DipArea
|
||||
gcmd_push gp0, rtmp_1, gp_SetArea_TopLeft | 0 << gp_b10_Y | 0 << gp_b10_X
|
||||
gcmd_push gp0, rtmp_1, gp_SetArea_BottomRight | Display_Height << gp_b10_Y | Display_Width << gp_b10_X
|
||||
gcmd_push gp0, rtmp_1, gp_SetOffset | 0 << gp_b10_Y | 0 << gp_b10_X
|
||||
; Clear the screen
|
||||
gcmd_push gp0, rtmp_1, gp_RectFillVM | Color_22
|
||||
gcmd_push gp0, rtmp_1, 0 << gp_b16_Y | 0 << gp_b16_X
|
||||
gcmd_push gp0, rtmp_1, Display_Height << gp_b16_Y | Display_Width << gp_b16_X
|
||||
|
||||
; Draw a flat-shaded quad
|
||||
gcmd_push gp0, rtmp_1, gp_Quad | Color_PS_CelticBlue
|
||||
gcmd_push gp0, rtmp_1, 15 * -1 + Display_HalfHeight << gp_b16_Y | 0 + Display_HalfWidth << gp_b16_X
|
||||
gcmd_push gp0, rtmp_1, 24 * -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
|
||||
; Draw a flat-shaded triangle
|
||||
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)
|
||||
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)
|
||||
jump_nlink gp_draw_tri_flat :: nop
|
||||
stack_release gp_draw_tri_flat__sp_size
|
||||
; Gourand shaded triangle
|
||||
load_imm rarg_1, Color_PS_PersianGreen
|
||||
load_imm rstatic_1, Color_PS_GoldenPoppy
|
||||
load_imm rstatic_2, Color_PS_CadmiumRed
|
||||
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 rstatic_0, 40 * -1 + Display_HalfHeight << gp_b16_Y | 60 + Display_HalfWidth << gp_b16_X
|
||||
jump_nlink gp_draw_tri_gouraud :: nop
|
||||
|
||||
; 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, 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
|
||||
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)
|
||||
add_si @img_cursor, @img_cursor, word ; @img_cursor ++
|
||||
add_ui @id, @id, -1 :: branch_ne_zero @id, loop_dma :: nop
|
||||
|
||||
idle:
|
||||
jump idle :: nop
|
||||
|
||||
.close
|
||||
+2
-1
@@ -39,4 +39,5 @@ function build-program { param(
|
||||
# build-program 'factorial' 'factorial'
|
||||
# build-program 'graphics_system' 'hellogpu'
|
||||
# build-program 'graphics_system' 'hello_gouraud'
|
||||
build-program 'graphics_system' 'hello_gp_routines'
|
||||
# build-program 'graphics_system' 'hello_gp_routines'
|
||||
build-program 'graphics_system' 'hello_image'
|
||||
|
||||
Reference in New Issue
Block a user